Skip to content

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

Merged
merged 1 commit into from
Mar 28, 2018

Conversation

mike-marcacci
Copy link
Contributor

@mike-marcacci mike-marcacci commented Mar 12, 2018

Issues

Add a note and example about minimizing CSS output in Webpack 4

@jsf-clabot
Copy link

jsf-clabot commented Mar 12, 2018

CLA assistant check
All committers have signed the CLA.

@codecov
Copy link

codecov bot commented Mar 12, 2018

Codecov Report

Merging #35 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@         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.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 9b1bd63...3ee2d38. Read the comment docs.

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):

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):

Copy link
Member

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**

@mike-marcacci
Copy link
Contributor Author

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):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Webpack => webpack :)

@mike-marcacci
Copy link
Contributor Author

mike-marcacci commented Mar 13, 2018

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):

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.

@mybrainishuge
Copy link

:)

README.md Outdated
filename: "[name].css",
chunkFilename: "[id].css"
}),
new OptimizeCssAssetsPlugin()
Copy link
Contributor

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(),
  ]
}

Copy link
Contributor Author

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?

Copy link
Contributor

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.

Copy link
Contributor Author

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?

Copy link
Member

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.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mike-marcacci friendly ping

@alexander-akait
Copy link
Member

//cc @michael-ciniawsky

@michael-ciniawsky michael-ciniawsky changed the title Fix #24 - Add information about minimization docs(README): add information about minimization Mar 20, 2018
@michael-ciniawsky michael-ciniawsky added this to the 0.2.1 milestone Mar 20, 2018
@mike-marcacci
Copy link
Contributor Author

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!

@alexander-akait
Copy link
Member

@mike-marcacci can you rebase PR?

@mike-marcacci
Copy link
Contributor Author

@evilebottnawi - good to go!

@alexander-akait alexander-akait merged commit ff72885 into webpack-contrib:master Mar 28, 2018
@robrichard
Copy link

@mike-marcacci is this the same as adding minimize: true to css-loader?

@mike-marcacci
Copy link
Contributor Author

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.

@michael-ciniawsky michael-ciniawsky removed this from the 0.4.3 milestone Aug 21, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants