-
-
Notifications
You must be signed in to change notification settings - Fork 6.3k
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
vite.config.js esbuild options are ignored, e.g. disabling minification or one of its aspects #6065
Comments
Any news on it? |
@kskalski @rosostolato I'd suggest to use the right property name :) It is export default defineConfig({
build: {
minify: false,
},
...
}) And then it magically works ;) |
@kyr0 as mentioned in this issue's description:
As mentioned in documentation (https://vitejs.dev/config/#esbuild) vite config has |
The relevant code is here: https://github.com/vitejs/vite/blob/main/packages/vite/src/node/plugins/esbuild.ts#L251 So |
I care most about |
Yup, wanted to set |
I bumped the repro to vite 3.0.0-beta.3, unfortunately the esbuild options are still ignored |
I guess there is still an override that forces
(https://github.com/vitejs/vite/pull/8754/files#) what is "es lib build" and can I choose in vite.config.js whether I'm using it or not? |
The esbuild options are not ignored. The options for |
Since we are defaulting |
I believe my issue is related to css files only and the (different than for .js files) options that are passed to esbuild. E.g. in my repro I added some debug to print which options are passed to esbuild and it differs for files other than .js output:
Is it possible that there is some css loader pipeline, which just passes |
Basically the problem is with this line vite/packages/vite/src/node/plugins/css.ts Line 1208 in c1667bb
it doesn't follow the user config, tweaking it solves my issue. |
Ah good fine. Yeah I forgot to update the CSS part.
I've thought about the different options while making the PR and landed with the current one as it makes reasoning the final options a bit easier. I'm open if anyone has thoughts or prefer an alternative resolve logic though and we can still change it before stable. Re the latter option, I'm not sure having the user to set all the options by default would be good for DX. |
@sapphi-red the way esbuild interprets options in https://github.com/evanw/esbuild/blob/0d4fae1f97b2013b78a293f1f19607df062a52f1/lib/shared/common.ts#L159-L162 vite/packages/vite/src/node/plugins/esbuild.ts Lines 319 to 324 in 8b77695
is only satisfied for true values in one of those fields, setting explicitly false on them will be ignored. I would definitely modify this check to something like minifyIdentifiers != null
|
Currently writing tests for it and I can see how setting // when one of `minify*` options are set (checked by != null)
if (
options.minifyIdentifiers != null ||
options.minifySyntax != null ||
options.minifyWhitespace != null
) {
return {
minifyIdentifiers: options.minifyIdentifiers != null ? options.minifyIdentifiers : true,
minifySyntax: options.minifySyntax != null ? options.minifySyntax : true,
minifyWhitespace: options.minifyWhitespace != null ? options.minifyWhitespace : true,
}
} when minifying. Curious to here thoughts on this so we don't have to change again 😅 |
That sounds good to me. 👍 (A nit pick, using |
Describe the bug
I'm trying to control how
esbuild
is performing minification due to some recent features that I would like to disable (evanw/esbuild#1755), however it seems that options specified invite.config.js
byesbuild
section are ignored, e.g. settingminify: false
there doesn't have any effect:Reproduction
This repo shows the problem
https://github.com/kskalski/snippets/tree/master/esbuild-minify-test
to preproduce:
npm i
npm run build
grep "\(foo\|bar\)" dist/assets/index.*.css
shows the rule.foo,.bar{color:red}
while originalApp.vue
has them as separate rulesNote that it is possible to completely disable minification by option
however I would like to have more fine grained control (affect specific
esbuild
options instead of completely disabling the pipeline). Also related is this issue #5619, which asks for splitting options between JS and CSS minification, here however I'm observing thatesbuild
config section is not correctly applied (though it is validated for correct property names).System Info
Used Package Manager
npm
Logs
Validations
The text was updated successfully, but these errors were encountered: