diff --git a/packages/vite/src/node/plugins/css.ts b/packages/vite/src/node/plugins/css.ts index fdbb8b24c3c4c2..7827a8951a6d89 100644 --- a/packages/vite/src/node/plugins/css.ts +++ b/packages/vite/src/node/plugins/css.ts @@ -248,6 +248,7 @@ const commonjsProxyRE = /[?&]commonjs-proxy/ const inlineRE = /[?&]inline\b/ const inlineCSSRE = /[?&]inline-css\b/ const styleAttrRE = /[?&]style-attr\b/ +const styleTagCloseRE = /<\/style(?=[\t\n\f\r />])/gi const functionCallRE = /^[A-Z_][.\w-]*\(/i const transformOnlyRE = /[?&]transform-only\b/ const nonEscapedDoubleQuoteRe = /(? { expect(cssFile).not.toMatch('#ffff00b3') }) +test.runIf(isBuild)('minify inline style', () => { + expect(readFile('dist/index.html')).toContain( + '', + ) +}) + +test.runIf(isBuild)('escapes closing style tags in inline CSS', () => { + expect(readFile('dist/index.html')).toContain( + '', + ) +}) + test.runIf(isBuild)('does not run the visitor again during minify', () => { expect(readFile('dist/media-query-visits.txt')).toBe('2') }) diff --git a/playground/css-lightningcss/index.html b/playground/css-lightningcss/index.html index 75d9eebafda16c..376d3930e5b049 100644 --- a/playground/css-lightningcss/index.html +++ b/playground/css-lightningcss/index.html @@ -1,5 +1,17 @@ + + + +