javascript - Write template string to .html file with Webpack -


i've got simple entry file called user.js so:

var styles   = require('../scss/user.scss'),     template = require('../pages/user.hbs');     html     = template({ styles: styles }); 

and i'd write contents of html .html file. here loaders webpack.config.js file:

loaders: [     {         test: /\.hbs/,         loader: 'file?name=[name].html!handlebars-loader'     },     {         test: /\.scss$/,         loader: extracttextplugin.extract('style-loader', 'css?localidentname='+ (process.env.node_env == 'prod' ? '__[hash:base64:5]' : '[local]__[hash:base64:5]') +'&sourcemap!autoprefixer?browsers=last 2 versions!sass?outputstyle=expanded')     } ] 

using way, user.hbs file written user.html file, doesn't have styles variable stuff in it.

does have workaround this? need html file compiled styles information scss file.

perhaps html-webpack-plugin work you. push handlebars template higher level. plugin can write needed references automatically.


Comments