Include *.mjml files in dist folder (api side)

Hi, this is the problem I’d like to resolve:

  1. I have to send some emails after user registration (welcome email, reset password, etc).
  2. I want to do that using MJML lib.
  3. Using MJML, you can write template email files like welcome.mjml, resetPassword.mjml, etc.
  4. *.mjml files are not included in api/dist bundle, so Iḿ not able to use my templates.

How to solve this?

Option 1

Create a templates.js file and define them as constants:

// templates.js

export const WELCOME_MJML = `......`
export const RESET_PASSWORD_MJML = `.......`

This works, but I’m not able to use the advantages of having a mjml file (use plugins for preview, color scheme, formatting, etc).

Option 2

Modify the Webpack config for copying my templates inside the compiled bundle.
I tried to follow the instructions from Webpack Configuration | RedwoodJS Docs but they are for the web side. I couldn’t get it to work on the api side.

This is what I tried:

  1. Install the copy-webpack-plugin pluging on api side:
$ cd api 
$ yarn add -D copy-webpack-plugin
  1. Create the file api/webpack.config.js:
const path = require('path');

module.exports = {
  // ...
  plugins: [
    new CopyWebpackPlugin({
      patterns: [
          from: path.resolve(__dirname, 'templates'),
          to: path.resolve(__dirname, 'dist/templates'),

But this don’t work. Any ideas?
Thanks in advance.

Does this post help?

How are you deployed?