Skip to content
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

Add a top-level terser option to allow users to customize the minifier #6752

Merged
merged 10 commits into from Oct 22, 2021

Conversation

screetBloom
Copy link
Contributor

@screetBloom screetBloom commented Oct 14, 2021

What kind of change does this PR introduce? (check at least one)

  • Bugfix
  • Feature
  • Code style update
  • Refactor
  • Docs
  • Underlying tools
  • Other, please describe:

Does this PR introduce a breaking change? (check one)

  • Yes
  • No

Other information

background

  • Form terser-webpack-plugin@5.2 we can custom minify
  • So Vue CLI 5 can support user to custom terser-webpack-plugin minify as esbuild, swc or uglifyJs 👇


Some data

// delete .cache before each build
yarn build --no-module
Vue CLI 5 demo
  • Generally, projects with more files will be more effective
  • I just tested the speed briefly, we have used it in the company’s project, and the build time can be reduced by about 20%

no cache, minify with default options




@screetBloom
Copy link
Contributor Author

screetBloom commented Oct 14, 2021

packages/@vue/cli-plugin-typescript/__tests__/tsPluginESLint.spec.js

Its test error reporting is confusing, and from the code logic, the test file is not written correctly

https://github.com/vuejs/vue-cli/blob/dev/packages/%40vue/cli-plugin-typescript/__tests__/tsPluginESLint.spec.js#L17-L20

ts-eslint demo project

@screetBloom screetBloom changed the title Feature/terser Feature/terser: Vue CLI 5 can support user to custom terser-webpack-plugin minify as esbuild, swc or uglifyJs Oct 14, 2021
@screetBloom screetBloom changed the title Feature/terser: Vue CLI 5 can support user to custom terser-webpack-plugin minify as esbuild, swc or uglifyJs Feature/terser: Vue CLI 5 can support user to custom minify as esbuild, swc or uglifyJs Oct 14, 2021
@screetBloom screetBloom changed the title Feature/terser: Vue CLI 5 can support user to custom minify as esbuild, swc or uglifyJs Vue CLI 5 can support user to custom minify as esbuild, swc or uglifyJs Oct 14, 2021
@screetBloom
Copy link
Contributor Author

screetBloom commented Oct 15, 2021

@sodatea

If you have time, take a look at this pr and give some feedback

Please forgive me, I'll be implementing more good solutions into Vue CLI5 in the near future🎸, so I'll probably keep bothering you

And there are some new ideas I would like to get feedback from your side 🎨🏄‍♂️

.prettierrc Outdated Show resolved Hide resolved
@sodatea
Copy link
Member

sodatea commented Oct 21, 2021

Vue CLI automatically runs the lint command after project creation. So the tests are correct.
It's failing now because the newly added .prettierrc at the workspace root alters the default configuration.

@screetBloom
Copy link
Contributor Author

screetBloom commented Oct 21, 2021

Vue CLI automatically runs the lint command after project creation. So the tests are correct. It's failing now because the newly added .prettierrc at the workspace root alters the default configuration.

PR updated

This test has timed out, You can try re-trigger it

This plugins test depends on luck, sometimes it does time out and fail

All tests in the local environment have passed

Copy link
Member

@sodatea sodatea left a comment

Choose a reason for hiding this comment

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

Looks good to me. One more thing: we should allow minify to be a function. That could be done in a separate PR.

@screetBloom
Copy link
Contributor Author

Looks good to me. One more thing: we should allow minify to be a function. That could be done in a separate PR.

ok, got it
I will finish it in another pr this week

packages/@vue/cli-service/lib/options.js Outdated Show resolved Hide resolved
@sodatea sodatea changed the title Vue CLI 5 can support user to custom minify as esbuild, swc or uglifyJs Add a top-level terser option to allow users to customize the minifier Oct 22, 2021
@sodatea
Copy link
Member

sodatea commented Oct 22, 2021

Thanks! I'm going to merge this PR.

One more thing: would you please open a new PR to update the documentation? https://github.com/vuejs/vue-cli/edit/next/docs/config/README.md

@sodatea sodatea merged commit 9aeafc0 into vuejs:dev Oct 22, 2021
@screetBloom
Copy link
Contributor Author

Thanks! I'm going to merge this PR.

One more thing: would you please open a new PR to update the documentation? https://github.com/vuejs/vue-cli/edit/next/docs/config/README.md

ok, Okay, I'll finish it.

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.

None yet

2 participants