How to compile a separate CSS file, unrelated to HTML? #104
binarykitchen
started this conversation in
General
Replies: 4 comments 13 replies
|
Probably should use your https://github.com/webdiscus/webpack-remove-empty-scripts ? |
2 replies
|
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'],
},
],
},
}; |
5 replies
CSS should be injected into email template with |
1 reply
|
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";
},
}, |
5 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
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?
All reactions