Tarlen
Tarlen

Reputation: 3797

Webpack email templates

I want to use Webpack for bundling my email templates.

I pretty much have a .html file for each of the templates, which references a common .scss file for styles.

I want the styles to be inlined in the HTML

Is this possible?

Upvotes: 5

Views: 2315

Answers (2)

arm5077
arm5077

Reputation: 302

If you want to use webpack, seems to me this is a job for inline-style-loader: https://www.npmjs.com/package/inline-style-loader

There's a demo for how to integrate this into your webpack.config.js file here: https://github.com/jbsouvestre/inline-style-loader/tree/master/demo

Upvotes: 2

iRyusa
iRyusa

Reputation: 394

You should use a gulp workflow with Juice ( https://github.com/Automattic/juice ), it should fit your needs !

Cf the doc :

To inline HTML without getting remote resources, using default options:

var juice = require('juice');

var result = juice("<style>div{color:red;}</style><div/>");

result will be:

<div style="color: red;"></div>

Upvotes: -1

Related Questions