vite.config.js esbuild options are ignored, e.g. disabling minification or one of its aspects
See original GitHub issueDescribe the bug
I’m trying to control how esbuild
is performing minification due to some recent features that I would like to disable (https://github.com/evanw/esbuild/issues/1755), however it seems that options specified in vite.config.js
by esbuild
section are ignored, e.g. setting minify: false
there doesn’t have any effect:
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
// https://vitejs.dev/config/
export default defineConfig({
esbuild: {
minify: false,
minifySyntax: false
},
plugins: [vue()]
})
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 rules
Note that it is possible to completely disable minification by option
{
build: {
minify: false
}
}
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 https://github.com/vitejs/vite/issues/5619, which asks for splitting options between JS and CSS minification, here however I’m observing that esbuild
config section is not correctly applied (though it is validated for correct property names).
System Info
System:
OS: Linux 4.4 Ubuntu 21.04 (Hirsute Hippo)
CPU: (8) x64 Intel(R) Core(TM) i7-8550U CPU @ 1.80GHz
Memory: 1.39 GB / 7.89 GB
Container: Yes
Shell: 5.1.4 - /bin/bash
Binaries:
Node: 12.21.0 - /usr/bin/node
npm: 7.5.2 - /usr/bin/npm
npmPackages:
@vitejs/plugin-vue: ^1.10.2 => 1.10.2
vite: ^2.7.0 => 2.7.1
Used Package Manager
npm
Logs
> vite build --debug
vite:config bundled config file loaded in 177.49ms +0ms
vite:config using resolved config: {
vite:config esbuild: { minify: false, minifySyntax: false },
...
Validations
- Follow our Code of Conduct
- Read the Contributing Guidelines.
- Read the docs.
- Check that there isn’t already an issue that reports the same bug to avoid creating a duplicate.
- Make sure this is a Vite issue and not a framework-specific issue. For example, if it’s a Vue SFC related bug, it should likely be reported to https://github.com/vuejs/vue-next instead.
- Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.
- The provided reproduction is a minimal reproducible example of the bug.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:8
- Comments:16 (5 by maintainers)
Top GitHub Comments
Any news on it?
That sounds good to me. 👍 (A nit pick, using
??
would shorten the code.)