mirror of
https://github.com/vitejs/vite.git
synced 2024-11-21 22:59:10 +00:00
fix(css): reset render cache on renderStart (#14326)
This commit is contained in:
parent
fcaf7491f4
commit
d334b3de8c
@ -406,7 +406,7 @@ export function cssPostPlugin(config: ResolvedConfig): Plugin {
|
||||
return {
|
||||
name: 'vite:css-post',
|
||||
|
||||
buildStart() {
|
||||
renderStart() {
|
||||
// Ensure new caches for every build (i.e. rebuilding in watch mode)
|
||||
pureCssChunks = new Set<RenderedChunk>()
|
||||
outputToExtractedCSSMap = new Map<NormalizedOutputOptions, string>()
|
||||
|
@ -61,6 +61,12 @@ export async function serve(): Promise<{ close(): Promise<void> }> {
|
||||
configFile: path.resolve(__dirname, '../vite.dyimport.config.js'),
|
||||
})
|
||||
|
||||
await build({
|
||||
root: rootDir,
|
||||
logLevel: 'warn', // output esbuild warns
|
||||
configFile: path.resolve(__dirname, '../vite.multiple-output.config.js'),
|
||||
})
|
||||
|
||||
await build({
|
||||
root: rootDir,
|
||||
logLevel: 'warn', // output esbuild warns
|
||||
|
6
playground/lib/src/main-multiple-output.js
Normal file
6
playground/lib/src/main-multiple-output.js
Normal file
@ -0,0 +1,6 @@
|
||||
// import file to test css build handling
|
||||
import './index.css'
|
||||
|
||||
export default async function message(sel) {
|
||||
document.querySelector(sel).textContent = 'success'
|
||||
}
|
6
playground/lib/src/sub-multiple-output.js
Normal file
6
playground/lib/src/sub-multiple-output.js
Normal file
@ -0,0 +1,6 @@
|
||||
// import file to test css build handling
|
||||
import './index.css'
|
||||
|
||||
export default async function message(sel) {
|
||||
document.querySelector(sel).textContent = 'success'
|
||||
}
|
39
playground/lib/vite.multiple-output.config.js
Normal file
39
playground/lib/vite.multiple-output.config.js
Normal file
@ -0,0 +1,39 @@
|
||||
import path from 'node:path'
|
||||
import { defineConfig } from 'vite'
|
||||
|
||||
const root = process.env.VITEST
|
||||
? path.resolve(__dirname, '../../playground-temp/lib')
|
||||
: __dirname
|
||||
|
||||
export default defineConfig({
|
||||
build: {
|
||||
lib: {
|
||||
// set multiple entrypoint to trigger css chunking
|
||||
entry: {
|
||||
main: path.resolve(__dirname, 'src/main-multiple-output.js'),
|
||||
sub: path.resolve(__dirname, 'src/sub-multiple-output.js'),
|
||||
},
|
||||
name: 'MyLib',
|
||||
},
|
||||
outDir: 'dist/multiple-output',
|
||||
rollupOptions: {
|
||||
// due to playground-temp, the `dir` needs to be relative to the resolvedRoot
|
||||
output: [
|
||||
{
|
||||
dir: path.resolve(root, 'dist/multiple-output/es'),
|
||||
format: 'es',
|
||||
entryFileNames: 'index.mjs',
|
||||
assetFileNames: 'assets/mylib.css',
|
||||
},
|
||||
{
|
||||
dir: path.resolve(root, 'dist/multiple-output/cjs'),
|
||||
format: 'cjs',
|
||||
entryFileNames: 'index.cjs',
|
||||
assetFileNames: 'assets/mylib.css',
|
||||
},
|
||||
],
|
||||
},
|
||||
cssCodeSplit: true,
|
||||
},
|
||||
cacheDir: 'node_modules/.vite-multiple-output',
|
||||
})
|
Loading…
Reference in New Issue
Block a user