-
Notifications
You must be signed in to change notification settings - Fork 519
feat(css minimize): add CSS minification in production build for all templates. #852
Conversation
@etimesg, It will cover your contributions to all .NET Foundation-managed open source projects. |
@etimesg, thanks for signing the contribution license agreement. We will now validate the agreement and then the pull request. |
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.
Thanks very much for this! I really appreciate your thoroughness in providing all the stats on the difference this makes.
Just a few minor tweaks and we can get this merged :)
@@ -18,7 +18,7 @@ module.exports = (env) => { | |||
rules: [ | |||
{ test: /\.ts$/, include: /ClientApp/, use: ['awesome-typescript-loader?silent=true', 'angular2-template-loader'] }, | |||
{ test: /\.html$/, use: 'html-loader?minimize=false' }, | |||
{ test: /\.css$/, use: ['to-string-loader', 'css-loader'] }, | |||
{ test: /\.css$/, use: [ 'to-string-loader', isDevBuild ? 'css-loader' : 'css-loader?minimize' ] }, |
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.
In a few cases you've added spaces inside the [...]
array, such as in this file, but not in some other cases (e.g., for ReactSpa's webpack.config.js
).
Would you be able to make the changes consistent with each other? Personally I'd prefer not having the extra spaces in any of them, but if you prefer them to be there, that's OK as long as they are all the same :) Thanks!
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.
Actually don't worry about this. It's a super-minor issue. I'll make a follow-up tweak to the spacing later.
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.
Thank you @SteveSanderson. In truthiness, the differences in spaces also bothered me, until I realized other parts of the templates were different, so I decide to keep it as it was. But now that I'm aware of your preferences for this project I'll make sure to use "no array spaces" as the standard on future PRs.
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.
Looks great - thanks! I really appreciate seeing all the stats on the difference it makes :)
@etimesg In case you got a notification with some other review comments from me, you can ignore it, because I realised my comments were wrong so I deleted them. |
As discussed on #844, this PR allows webpack to compress all CSS using the
minimize
property from the css-loader plugin. It only applies when--env.prod
is provided.Please note this will also compress any css passed through webpack, therefore you should expect a small reduction in size on files other than
vendor.css
. Out of curiosity, I'm posting a comparison for each template, showing all the affected files their corresponding sizes before and after this change.Finally, I also would like to highlight the following passage from the css-loader project:
Although I couldn't find any errors while testing the templates, I encourage everyone to read the css-loader documentation in case of a css compression error.
Angular2Spa Template
AureliaSpa Template
KnockoutSpa Template
ReactReduxSpa Template
ReactSpa Template
VueSpa Template
Please, feel free to recommend/perform any necessary modifications.