Hi, this is the problem I’d like to resolve:
- I have to send some emails after user registration (welcome email, reset password, etc).
- I want to do that using MJML lib.
- Using MJML, you can write template email files like
welcome.mjml
,resetPassword.mjml
, etc. -
*.mjml
files are not included inapi/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:
- Install the
copy-webpack-plugin
pluging on api side:
$ cd api
$ yarn add -D copy-webpack-plugin
- 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.