Skip to content

Commit 88baa53

Browse files
authoredJul 19, 2022
feat(css): use esbuild.log* options when minifying (#9210)
1 parent af6088f commit 88baa53

File tree

5 files changed

+25
-1
lines changed

5 files changed

+25
-1
lines changed
 

‎packages/vite/src/node/plugins/css.ts

+8-1
Original file line numberDiff line numberDiff line change
@@ -1249,18 +1249,25 @@ async function minifyCSS(css: string, config: ResolvedConfig) {
12491249
function resolveEsbuildMinifyOptions(
12501250
options: ESBuildOptions
12511251
): TransformOptions {
1252+
const base: TransformOptions = {
1253+
logLevel: options.logLevel,
1254+
logLimit: options.logLimit,
1255+
logOverride: options.logOverride
1256+
}
1257+
12521258
if (
12531259
options.minifyIdentifiers != null ||
12541260
options.minifySyntax != null ||
12551261
options.minifyWhitespace != null
12561262
) {
12571263
return {
1264+
...base,
12581265
minifyIdentifiers: options.minifyIdentifiers ?? true,
12591266
minifySyntax: options.minifySyntax ?? true,
12601267
minifyWhitespace: options.minifyWhitespace ?? true
12611268
}
12621269
} else {
1263-
return { minify: true }
1270+
return { ...base, minify: true }
12641271
}
12651272
}
12661273

‎playground/css/__tests__/css.spec.ts

+7
Original file line numberDiff line numberDiff line change
@@ -442,3 +442,10 @@ test('aliased css has content', async () => {
442442
// expect(await page.textContent('.aliased-content')).toMatch('.aliased')
443443
expect(await getColor('.aliased-module')).toBe('blue')
444444
})
445+
446+
test.runIf(isBuild)('warning can be suppressed by esbuild.logOverride', () => {
447+
serverLogs.forEach((log) => {
448+
// no warning from esbuild css minifier
449+
expect(log).not.toMatch('unsupported-css-property')
450+
})
451+
})

‎playground/css/main.js

+2
Original file line numberDiff line numberDiff line change
@@ -104,3 +104,5 @@ import aliasModule from '#alias-module'
104104
document
105105
.querySelector('.aliased-module')
106106
.classList.add(aliasModule.aliasedModule)
107+
108+
import './unsupported.css'

‎playground/css/unsupported.css

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.unsupported {
2+
overflow-x: hidden;
3+
}

‎playground/css/vite.config.js

+5
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ module.exports = {
77
build: {
88
cssTarget: 'chrome61'
99
},
10+
esbuild: {
11+
logOverride: {
12+
'unsupported-css-property': 'silent'
13+
}
14+
},
1015
resolve: {
1116
alias: {
1217
'@': __dirname,

0 commit comments

Comments
 (0)