-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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: abstract minify and use value for all modes #3965
Conversation
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.
Another thought is that if build.minify has some confusion with build.optimization.minifier?
How about htmlMinify or some name else?
lib/builder/generator.js
Outdated
// Legacy workaround for obsolete options.generate.minify | ||
|
||
if (typeof this.options.build.minify === 'undefined') { | ||
this.options.build.minify = { |
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 this can be default value of build.minify directly.
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.
The problem is that we'd possibly introduce a breaking change because this value is not equal to minify: true
or the resulting default values (which was the value for SSR/SPA layout minification).
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.
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 the past things like script injection broke because of minification (where closing tags were removed), so I can't judge which problems the changed setting might cause. 🙈
But it shouldn't be up to me
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, but current default options are more conservative than true, right? It should only fix sth instead of breaking 😅
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! No, they are not. In this situation I completely agree!
lib/builder/webpack/client.js
Outdated
@@ -47,13 +47,19 @@ export default class WebpackClientConfig extends WebpackBaseConfig { | |||
plugins() { | |||
const plugins = super.plugins() | |||
|
|||
// Legacy workaround for obsolete options.generate.minify | |||
|
|||
if (typeof this.options.build.minify === 'undefined') { |
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.
If we make above value as deault value, this part can be removed
I agree on changing the name to |
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.
@manniL just need to fix the unit test, otherwise LGTM
Codecov Report
@@ Coverage Diff @@
## dev #3965 +/- ##
==========================================
- Coverage 97.56% 97.41% -0.16%
==========================================
Files 18 18
Lines 1233 1237 +4
Branches 337 338 +1
==========================================
+ Hits 1203 1205 +2
- Misses 29 31 +2
Partials 1 1
Continue to review full report at Codecov.
|
I'll move all |
Refactored the changes to use the former |
682fb33
to
ef5fb45
Compare
lib/common/options.js
Outdated
@@ -209,6 +209,14 @@ Options.from = function (_options) { | |||
delete options.render.gzip | |||
} | |||
|
|||
// Legacy: Override build.htmlMinify with generate.minify if present | |||
if (this.options.generate.minify) { | |||
this.options.build.htmlMinify = this.options.generate.minify |
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.
This part still have the issue we just discussed, I think it should only be executed in generation
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.
But how can we distinguish between generated
and "normal" SSR?
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.
Unfortunately we can’t, so maybe just warning default value willl be applied but not override build options? @pi0 How do you think?
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.
That would be a SOFT BREAKING CHANGE :D Breaking change but warn to fix it :D But i agree.
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.
That's why I was unsure if we should really proceed this way. Also because can't oversee how much damage the new "defaults" can cause for SSR HTML minification 🤔
To avoid breaking changes, the minification settings will be overridden in the We can then introduce the minification improvements that are set as default values of |
lib/builder/generator.js
Outdated
if (this.options.generate.minify) { | ||
minificationOption = this.options.generate.minify | ||
consola.warn('generate.minify has been deprecated. Use build.htmlMinify instead!') |
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.
If we all agree to do this way, I suggest adding a message that this option will be removed in 2.1
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.
You mean generate.minify
? Though it's not super clean, I wouldn't remove the override in the next minor version. Otherwise, we don't follow semver.
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, what I mean is just making warning message more clear
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.
Would ...deprecated and will be removed in the next major version
be sufficient?
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, good
I have no clue why the CI fails. Will investigate later on. Update: I have a slight feeling that the old Update 2: My feeling was right 🙈 |
I had to remove |
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.
Good for me, could you add a PR to nuxt/docs?
Will add a doc PR, yup! |
@Atinux PR added and linked. |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Types of changes
Description
Currently, we use
generate.minify
for configuring thehtml-minifier
ingenerate
mode.With this PR we can use
build.minify
for all modes to fine-tune the minifier.The value of
build.minify
will fall back to the old values in the respective modes to avoid a breaking change.Resolves #3961, resolves #3964
Checklist: