Add ability to skip files in UglifyJs via user-defined function#560
Add ability to skip files in UglifyJs via user-defined function#560sokra merged 2 commits intowebpack:masterfrom
Conversation
|
Could you use a similar logic like in A (defaults to http://webpack.github.io/docs/configuration.html#module-loaders |
|
Great idea @sokra, I've updated the PR. Long term this logic could be extracted and held separate in a filtering module to keep the code DRY. |
Add ability to skip files in UglifyJs via user-defined function
|
I might be mistaken, but I don't think this code does what this pull-request intended. Right now it runs the regexp matches as a filter against "files" which is an array of the generated chunks. Shouldn't it run it against the individual required modules? I'm not sure what use there is in telling it to exclude uglifying a whole generated chunk, especially since webpack is usually just generating one chunk. |
|
@snapwich sorry for not being clear enough in the PR description. You're right, the change here affects the whole bundle. My use case is that one of the bundles contains a legacy JS file that should not be minified and I want to prevent that file form being uglified. It would be better to exclude just a single file instead of whole chunk but I haven't found a way to do that with the webpack plugin system. |
|
I've just created a tiny loader for this https://github.com/bestander/uglify-loader |
Use case: User has some legacy library that breaks when treated with UglifyJs.
This change gives user a ability to exclude some of the files by conveniently providing custom function (via options) that will decide if a particular file should be skipped.