-
-
Notifications
You must be signed in to change notification settings - Fork 389
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
feat(options): add moduleFilename option #381
feat(options): add moduleFilename option #381
Conversation
Codecov Report
@@ Coverage Diff @@
## master #381 +/- ##
==========================================
+ Coverage 64.93% 65.19% +0.25%
==========================================
Files 4 4
Lines 405 408 +3
Branches 82 83 +1
==========================================
+ Hits 263 266 +3
Misses 118 118
Partials 24 24
Continue to review full report at Codecov.
|
Can you rebase, thanks for PR, good work! |
ef33e7d
to
89272ff
Compare
done |
when will this pr be merged? |
This doesn't work on chunks that are split out with SplitChunksPlugin – only works for entries. But our team found that new MiniCssExtractPlugin({
chunkFilename: ({ chunk }) => {
if (chunk.entryModule) {
// extracted from entry
return '[name].[contenthash].css';
} else {
// extracted from split chunks
return 'common/css/[name].[contenthash].css'
}
},
}) |
This PR contains a:
Motivation / Use-Case
The
filename
option currently takes a string the enables devs to customize the filename of the generated css file. This works well and the customized filename is created in the same output directory as the js file it is extracted from, however there are cases when the generated files may need to be in different directories. This change enables modifying thefilenameTemplate
using chunk data.Use Case:
webpack.config.js -
entry
The above config will create
dist/main.js
anddemo/assets/js/demo.js
.Use:
webpack.config.js -
plugins
We can change the output directory, chunkhash length and more by using a function that gets called during
compilation.mainTemplate.hooks.renderManifest
.Breaking Changes
None
Additional Info