From 1b820da124e9b0864df60a08e72240f5f4446ef1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=BF=A0=20/=20green?= Date: Sun, 19 Jun 2022 15:13:03 +0900 Subject: [PATCH] fix: revert #5902, fix #8243 (#8654) --- packages/vite/src/node/plugins/css.ts | 8 +--- playground/legacy/__tests__/legacy.spec.ts | 7 +--- playground/legacy/package.json | 1 - playground/legacy/vite.config-dynamic-css.js | 39 -------------------- 4 files changed, 3 insertions(+), 52 deletions(-) delete mode 100644 playground/legacy/vite.config-dynamic-css.js diff --git a/packages/vite/src/node/plugins/css.ts b/packages/vite/src/node/plugins/css.ts index 45af9233bf4560..a2728507093401 100644 --- a/packages/vite/src/node/plugins/css.ts +++ b/packages/vite/src/node/plugins/css.ts @@ -492,11 +492,7 @@ export function cssPostPlugin(config: ResolvedConfig): Plugin { // this is a shared CSS-only chunk that is empty. pureCssChunks.add(chunk.fileName) } - if ( - opts.format === 'es' || - opts.format === 'cjs' || - opts.format === 'system' - ) { + if (opts.format === 'es' || opts.format === 'cjs') { const cssAssetName = chunk.name + '.css' chunkCSS = resolveAssetUrlsInCss(chunkCSS, cssAssetName) @@ -558,7 +554,7 @@ export function cssPostPlugin(config: ResolvedConfig): Plugin { .join('|') .replace(/\./g, '\\.') const emptyChunkRE = new RegExp( - opts.format === 'es' || opts.format === 'system' + opts.format === 'es' ? `\\bimport\\s*["'][^"']*(?:${emptyChunkFiles})["'];\n?` : `\\brequire\\(\\s*["'][^"']*(?:${emptyChunkFiles})["']\\);\n?`, 'g' diff --git a/playground/legacy/__tests__/legacy.spec.ts b/playground/legacy/__tests__/legacy.spec.ts index f68371b1df7438..4825757830a901 100644 --- a/playground/legacy/__tests__/legacy.spec.ts +++ b/playground/legacy/__tests__/legacy.spec.ts @@ -60,12 +60,7 @@ test('correctly emits styles', async () => { // dynamic import css test('should load dynamic import with css', async () => { await page.click('#dynamic-css-button') - await untilUpdated( - () => - page.$eval('#dynamic-css', (node) => window.getComputedStyle(node).color), - 'rgb(255, 0, 0)', - true - ) + await untilUpdated(() => getColor('#dynamic-css'), 'red', true) }) describe.runIf(isBuild)('build', () => { diff --git a/playground/legacy/package.json b/playground/legacy/package.json index 53657df1c6b84f..4d6549302951df 100644 --- a/playground/legacy/package.json +++ b/playground/legacy/package.json @@ -6,7 +6,6 @@ "dev": "vite", "build": "vite build --debug legacy", "build:custom-filename": "vite --config ./vite.config-custom-filename.js build --debug legacy", - "build:dynamic-css": "vite --config ./vite.config-dynamic-css.js build --debug legacy", "build:multiple-output": "vite --config ./vite.config-multiple-output.js build", "debug": "node --inspect-brk ../../packages/vite/bin/vite", "preview": "vite preview" diff --git a/playground/legacy/vite.config-dynamic-css.js b/playground/legacy/vite.config-dynamic-css.js deleted file mode 100644 index 10565768ac4d49..00000000000000 --- a/playground/legacy/vite.config-dynamic-css.js +++ /dev/null @@ -1,39 +0,0 @@ -const fs = require('fs') -const path = require('path') -const legacy = require('@vitejs/plugin-legacy').default - -module.exports = { - plugins: [ - legacy({ - targets: 'IE 11' - }) - ], - - build: { - cssCodeSplit: true, - manifest: true, - rollupOptions: { - output: { - chunkFileNames(chunkInfo) { - if (chunkInfo.name === 'immutable-chunk') { - return `assets/${chunkInfo.name}.js` - } - - return `assets/chunk-[name].[hash].js` - } - } - } - }, - - // special test only hook - // for tests, remove `