-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MiniCssExtractPlugin compatible? #3
Comments
i did not test with css and minicssplugin tbh so no idea |
I just tried this plugin in a project with MiniCssExtractPlugin. The output of the initial css chunk still contain the chunkhash, like |
I hardcoded the following plugin in our react-scripts fork class ChunkNamesPlugin {
apply(compiler) {
compiler.hooks.compilation.tap('ChunkNamesPlugin', compilation => {
compilation.chunkTemplate.hooks.renderManifest.intercept({
register(tapInfo) {
if (tapInfo.name === 'JavascriptModulesPlugin') {
const originalFn = tapInfo.fn;
tapInfo.fn = (result, options) => {
const chunkName = options.chunk.name;
// Don't mutate options passed to other plugins
let customOpts = { ...options };
if (chunkName === 'main' || chunkName === 'vendors~main') {
customOpts.outputOptions = {
...options.outputOptions,
chunkFilename: 'js/[name].chunk.js',
};
const hasCss =
result[0] &&
result[0].identifier.startsWith('mini-css-extract-plugin');
if (hasCss) {
result[0].filenameTemplate = 'css/[name].chunk.css';
}
}
originalFn(result, customOpts);
};
}
return tapInfo;
},
});
});
}
} That's how I managed to avoid chunkhash in initial .css chunks. Maybe it can serve as an example to support MiniCssExtractPlugin in this lib. |
Hi thanks for you work on this.
did the plugin should work with css chunk and with MiniCssExtractPlugin?
thanks
The text was updated successfully, but these errors were encountered: