eladnava/mailgen

Huge issues with webpack

Closed this issue · 3 comments

Hey there,

I tried using mailgen with webpack in node (for an AWS Lambda function) and it was quite the nightmare :)

Granted, most of the issues were with sub-dependencies such as juice's, but the fact that mailgen caches the theme at runtime from a local file was messing with the paths after compiling via webpack.

I'm not sure if this is something fixable (short of including the default themes in the loaded code itself), but I just wanted to put this out there for anyone else having issues when using webpack.

Thanks for the great work on mailgen so far!

Hi @andreipopovici,
Thanks for your report!

There must be some other solution than to bundle the HTML themes inside JavaScript files. What happens to the theme path after you compile with webpack? How did the new path look like? Maybe we can detect webpack compilation and build a different path to the theme in that case.

Honestly, I wouldn't worry about it too much (from mailgen's perspective). My issues were mostly because the compiled code needed to be packaged and served separately from the development code. The path is correct if including node_modules/mailgen in the uploaded Lambda package and excluding mailgen from webpack compilation (using https://github.com/kevlened/copy-webpack-plugin)

However, some of the dependencies two levels deep use dynamic requires, which are poorly supported by webpack, for good reason.

I guess we can close this issue, it was mostly a heads-up to anyone trying to use mailgen with webpack and AWS Lambda :)

Cool, thanks for documenting this! 👍