-
-
Notifications
You must be signed in to change notification settings - Fork 386
docs(README): add information about minimization #35
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
Conversation
Codecov Report
@@ Coverage Diff @@
## master #35 +/- ##
====================================
Coverage 0% 0%
====================================
Files 3 3
Lines 157 157
Branches 32 32
====================================
Misses 125 125
Partials 32 32 Continue to review full report at Codecov.
|
README.md
Outdated
@@ -66,6 +66,36 @@ module.exports = { | |||
} | |||
``` | |||
|
|||
### Minimizing For Production | |||
|
|||
While Webpack 5 is likely to come with a CSS minimizer built-in, with Webpack 4 you need to bring your own. To minify your the output, use a plugin like optimize-css-assets-webpack-plugin](https://github.com/NMFR/optimize-css-assets-webpack-plugin): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you have a typo :)
"To minify your the output"
Also, I think you're missing an opening square bracket for the plugin link:
[optimize-css-assets-webpack-plugin]
@mike-marcacci
README.md
Outdated
### Minimizing For Production | ||
|
||
While Webpack 5 is likely to come with a CSS minimizer built-in, with Webpack 4 you need to bring your own. To minify your the output, use a plugin like optimize-css-assets-webpack-plugin](https://github.com/NMFR/optimize-css-assets-webpack-plugin): | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add the filename here **webpack.config.js**
Woof, my apologies for the sloppiness! Fixed :) |
README.md
Outdated
@@ -68,7 +68,9 @@ module.exports = { | |||
|
|||
### Minimizing For Production | |||
|
|||
While Webpack 5 is likely to come with a CSS minimizer built-in, with Webpack 4 you need to bring your own. To minify your the output, use a plugin like optimize-css-assets-webpack-plugin](https://github.com/NMFR/optimize-css-assets-webpack-plugin): | |||
While Webpack 5 is likely to come with a CSS minimizer built-in, with Webpack 4 you need to bring your own. To minify your the output, use a plugin like [optimize-css-assets-webpack-plugin](https://github.com/NMFR/optimize-css-assets-webpack-plugin): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Webpack => webpack
:)
Haha, I hope you squash changes while merging! 🤪 |
README.md
Outdated
@@ -66,6 +66,38 @@ module.exports = { | |||
} | |||
``` | |||
|
|||
### Minimizing For Production | |||
|
|||
While webpack 5 is likely to come with a CSS minimizer built-in, with webpack 4 you need to bring your own. To minify your the output, use a plugin like [optimize-css-assets-webpack-plugin](https://github.com/NMFR/optimize-css-assets-webpack-plugin): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mike-marcacci Hey, it's me again. Sorry to be picky, but I think you still have a typo:
"To minify your the output"
I think you want either "your" or "the", but not both.
:) |
README.md
Outdated
filename: "[name].css", | ||
chunkFilename: "[id].css" | ||
}), | ||
new OptimizeCssAssetsPlugin() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm this shouldn't by at
optimization: {
minimizer: [
new OptimizeCssAssetsPlugin(),
]
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe! I couldn't find docs for this syntax when I created this issue, and I have things working as written. Is it that simple? Just add it to optimization.minimizer
? Does doing this remove the built-in one for JS?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah it will replace minimizer options, defaults are at https://github.com/webpack/webpack/blob/master/lib/WebpackOptionsDefaulter.js#L265-L281
and apply at https://github.com/webpack/webpack/blob/master/lib/WebpackOptionsApply.js#L334-L338
basic the reason to use optimization.minimizer
is to don't run optimisation on development mode.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, interesting. Is this the preferred way then?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yep, also make sure to add the UglifyJsPlugin
too as the default is overriden.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mike-marcacci friendly ping
//cc @michael-ciniawsky |
Sorry for the delay – we were in Indian Creek this week and had no cell service. I've tested this syntax, and it works. Let me know if there's any other changes you'd make! |
@mike-marcacci can you rebase PR? |
@evilebottnawi - good to go! |
@mike-marcacci is this the same as adding |
Hey @robrichard, I'm not 100% sure actually! It seems there are many ways to add minimization, but based on the above conversation the way described in this PR is considered most idiomatic for webpack 4+ (although it is certainly less ergonomic than some of the others). I personally have no preference, so I'll defer to the opinion of those more intimately involved with the internals of webpack. |
Issues
Add a note and example about minimizing CSS output in Webpack 4