How to compile a separate CSS file, unrelated to HTML? #104
Replies: 4 comments 13 replies
-
Probably should use your https://github.com/webdiscus/webpack-remove-empty-scripts ? |
Beta Was this translation helpful? Give feedback.
-
If you render a template into HTML You can see the working example in the test case entry-sass-resolve-url: const path = require('path');
const HtmlBundlerPlugin = require('html-bundler-webpack-plugin');
module.exports = {
output: {
path: path.join(__dirname, 'dist/'),
},
entry: {
// compile separate CSS (not used in any template in this config)
vendor: './src/vendor/style.scss', // => dist/assets/css/vendor.1234abcd.css
// render the template with related CSS
index: './src/views/index.html',
},
plugins: [
new HtmlBundlerPlugin({
css: {
filename: 'assets/css/[name].[contenthash:8].css',
},
}),
],
module: {
rules: [
{
test: /\.(css|sass|scss)$/,
use: [ 'css-loader','sass-loader'],
},
],
},
}; |
Beta Was this translation helpful? Give feedback.
-
CSS should be injected into email template with |
Beta Was this translation helpful? Give feedback.
-
For simplicity without adding an extra package, I went for: ...
entry: { index: clientJsEntry, email: emailStyles },
...
css: {
filename: function (pathData: PathData) {
if (pathData.chunk?.name === "email") {
return "css/[name].css";
}
return "css/[name].[contenthash].css";
},
}, |
Beta Was this translation helpful? Give feedback.
-
As mentioned in the Entry Options it has to be a HTML template.
What if you run a full-stack project, having email templates with their own CSS? How to compile their CSS, unrelated to the HTML entry option?
Beta Was this translation helpful? Give feedback.
All reactions