Vite is not minifying output files #11458
-
|
Here is a log where I run And my config file: import { resolve } from 'node:path';
import react from '@vitejs/plugin-react';
import { defineConfig } from 'vite';
import { version } from './package.json';
import reiconify from 'vite-plugin-reiconify';
export default defineConfig({
define: {
VERSION: JSON.stringify(version),
},
plugins: [react(), reiconify()],
build: {
lib: {
entry: resolve(__dirname, 'src/index.jsx'),
formats: ['es'],
},
},
server: {
port: 9010,
proxy: {
'/token': 'http://localhost:9090',
'/user': 'http://localhost:9090',
},
},
});However the output code is not minified: This does be my first time using vite lib mode, and when deleting Does anyone know what's going wrong? If it is a bug I believe someone would report this to vite, however I am not finding one. So probably there is somthing wrong with my configuration? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 5 replies
-
|
Note the you can use |
Beta Was this translation helpful? Give feedback.
-
|
Yeah... Vite minification for ESM lib is still broken. Default minifier does not minify whitespaces (as was mentioned before) and terser simpy does not minify it at all. |
Beta Was this translation helpful? Give feedback.

build.minify
Note the
build.minifyoption does not minify whitespaces when using the'es'format in lib mode, as it removes pure annotations and breaks tree-shaking.you can use
terser