Skip to content

Commit

Permalink
fix: skip asset emit for legacy output
Browse files Browse the repository at this point in the history
fix: #3296
  • Loading branch information
underfin committed May 9, 2021
1 parent d555dd6 commit 8d6d810
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
3 changes: 3 additions & 0 deletions packages/plugin-legacy/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,9 @@ function viteLegacyPlugin(options = {}) {
// @ts-ignore avoid esbuild transform on legacy chunks since it produces
// legacy-unsafe code - e.g. rewriting object properties into shorthands
opts.__vite_skip_esbuild__ = true
// @ts-ignore
// inject flag to prevent emit assets for legacy bundle
opts.__vite_legacy = true

const needPolyfills =
options.polyfills !== false && !Array.isArray(options.polyfills)
Expand Down
4 changes: 4 additions & 0 deletions packages/vite/src/node/plugins/css.ts
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,10 @@ export function cssPostPlugin(config: ResolvedConfig): Plugin {
},

async generateBundle(opts, bundle) {
// @ts-ignore injected by @vitejs/plugin-legacy
if (opts.__vite_legacy) {
return
}
// remove empty css chunks and their imports
if (pureCssChunks.size) {
const emptyChunkFiles = [...pureCssChunks]
Expand Down

0 comments on commit 8d6d810

Please sign in to comment.