You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When setting up a new Vite project to build a package, all output formats appear to be minified except for the es / ES module output file.
In my testing, cjs, iife, and umd builds are all properly minified by default, bug es is not (when using build.minify, passing true, "esbuild", or "terser", or when not specifying build.minify`).
I've reproduced in a sample repo with a new Vite app using typescript and pnpm.
The following is the four files in the dist/ folder after running vite build.
Workaround:
It looks like using esbuild.minify = true as a config option works.
It's possible this is the intended behavior and I misunderstood the docs -- if so, feel free to close this!
This was scaffolded with pnpm create vite with the vanilla TS setup, and the following steps:
Add an index.ts file to test minifying
Add the build configuration included below
I've reproduced on my machine here with the following vite.config.ts:
import{defineConfig}from"vite";exportdefaultdefineConfig({/** * Uncomment the following to make minification work for `es` outputs. */// esbuild: {// minify: true,// },build: {minify: true,lib: {name: 'lib',entry: 'src/index.ts',formats: ['es','cjs','iife','umd'],}}})
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.
Describe the bug
When setting up a new Vite project to build a package, all output formats appear to be minified except for the
es
/ ES module output file.In my testing,
cjs
,iife
, andumd
builds are all properly minified by default, buges
is not (when usingbuild.minify
, passingtrue
,"esbuild", or
"terser", or when not specifying
build.minify`).I've reproduced in a sample repo with a new Vite app using typescript and pnpm.
The following is the four files in the
dist/
folder after runningvite build
.Workaround:
It looks like using
esbuild.minify = true
as a config option works.It's possible this is the intended behavior and I misunderstood the docs -- if so, feel free to close this!
Reproduction
https://github.com/oscarnewman/vite-minify-issue-reproduction
See
build.log
for the build log.This was scaffolded with
pnpm create vite
with thevanilla TS
setup, and the following steps:index.ts
file to test minifyingbuild
configuration included belowI've reproduced on my machine here with the following
vite.config.ts
:System Info
System: OS: macOS 12.0.1 CPU: (8) arm64 Apple M1 Pro Memory: 188.69 MB / 32.00 GB Shell: 5.8 - /bin/zsh Binaries: Node: 16.13.1 - /var/folders/c_/36b_bwk55pqd539xbk065m_00000gp/T/fnm_multishells/60927_1639202104485/bin/node Yarn: 1.22.15 - /var/folders/c_/36b_bwk55pqd539xbk065m_00000gp/T/fnm_multishells/60927_1639202104485/bin/yarn npm: 8.1.2 - /var/folders/c_/36b_bwk55pqd539xbk065m_00000gp/T/fnm_multishells/60927_1639202104485/bin/npm Browsers: Edge: 96.0.1054.53 Firefox: 95.0 Safari: 15.1 npmPackages: vite: ^2.7.0 => 2.7.1
Used Package Manager
pnpm
Logs
Validations
The text was updated successfully, but these errors were encountered: