vite: vite.config.js esbuild options are ignored, e.g. disabling minification or one of its aspects

Describe 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:

  1. npm i
  2. npm run build
  3. grep "\(foo\|bar\)" dist/assets/index.*.css shows the rule .foo,.bar{color:red} while original App.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

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 8
  • Comments: 16 (5 by maintainers)

Most upvoted comments

Any news on it?

That sounds good to me. 👍 (A nit pick, using ?? would shorten the code.)