fix(css): don't transform sass function calls with namespace (#18414)

This commit is contained in:
翠 / green 2024-10-21 19:40:02 +09:00 committed by GitHub
parent ddee0ad38f
commit dbb260499f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
10 changed files with 22 additions and 22 deletions

View File

@ -197,7 +197,7 @@ const commonjsProxyRE = /\?commonjs-proxy/
const inlineRE = /[?&]inline\b/
const inlineCSSRE = /[?&]inline-css\b/
const styleAttrRE = /[?&]style-attr\b/
const functionCallRE = /^[A-Z_][\w-]*\(/i
const functionCallRE = /^[A-Z_][.\w-]*\(/i
const transformOnlyRE = /[?&]transform-only\b/
const nonEscapedDoubleQuoteRe = /(?<!\\)"/g

View File

@ -145,11 +145,11 @@ describe.runIf(isServe)('serve', () => {
"/root/imported-nested.sass",
],
"sourcesContent": [
"@import "/imported-nested.sass"
"@use "/imported-nested.sass"
.imported
&-sass
color: $primary
color: imported-nested.$primary
",
"$primary: red
",

View File

@ -1,5 +1,5 @@
@import "/imported-nested.sass"
@use "/imported-nested.sass"
.imported
&-sass
color: $primary
color: imported-nested.$primary

View File

@ -32,7 +32,7 @@ export default defineConfig({
},
},
sass: {
silenceDeprecations: ['legacy-js-api'],
silenceDeprecations: ['legacy-js-api', 'import'],
},
},
},

View File

@ -20,6 +20,6 @@ $var: '/ok.png';
$var2: '/OK.PNG';
.sass-url-starts-with-function-call {
background: url(to-lower-case($var2));
background: url(string.to-lower-case($var2));
background-position: center;
}

View File

@ -1,13 +1,13 @@
@import '=/nested'; // alias + custom index resolving -> /nested/_index.scss
@import '=/nested/partial'; // sass convention: omitting leading _ for partials
@import '@vitejs/test-css-dep'; // package w/ sass entry points
@import '@vitejs/test-css-dep-exports'; // package with a sass export mapping
@import '@vitejs/test-scss-proxy-dep'; // package with a sass proxy import
@import 'virtual-dep'; // virtual file added through importer
@import '=/pkg-dep'; // package w/out sass field
@import '=/weapp.wxss'; // wxss file
@import 'virtual-file-absolute';
@import '=/scss-dir/main.scss'; // "./dir" reference from vite custom importer
@use '=/nested'; // alias + custom index resolving -> /nested/_index.scss
@use '=/nested/partial'; // sass convention: omitting leading _ for partials
@use '@vitejs/test-css-dep'; // package w/ sass entry points
@use '@vitejs/test-css-dep-exports'; // package with a sass export mapping
@use '@vitejs/test-scss-proxy-dep'; // package with a sass proxy import
@use 'virtual-dep'; // virtual file added through importer
@use '=/pkg-dep'; // package w/out sass field
@use '=/weapp.wxss'; // wxss file
@use 'virtual-file-absolute';
@use '=/scss-dir/main.scss'; // "./dir" reference from vite custom importer
.sass {
/* injected via vite.config.js */

View File

@ -1 +1 @@
@import './dir';
@use './dir';

View File

@ -1 +1 @@
@import '@vitejs/test-scss-proxy-dep-nested/index.css';
@use '@vitejs/test-scss-proxy-dep-nested/index.css';

View File

@ -34,7 +34,7 @@ export default defineConfig({
},
load() {
return {
contents: `@import "${pathToFileURL(path.join(import.meta.dirname, 'file-absolute.scss')).href}"`,
contents: `@use "${pathToFileURL(path.join(import.meta.dirname, 'file-absolute.scss')).href}"`,
syntax: 'scss',
}
},

View File

@ -69,7 +69,7 @@ export default defineConfig({
function (url) {
return url === 'virtual-file-absolute'
? {
contents: `@import "${pathToFileURL(path.join(import.meta.dirname, 'file-absolute.scss')).href}"`,
contents: `@use "${pathToFileURL(path.join(import.meta.dirname, 'file-absolute.scss')).href}"`,
}
: null
},
@ -77,7 +77,7 @@ export default defineConfig({
return url.endsWith('.wxss') ? { contents: '' } : null
},
],
silenceDeprecations: ['legacy-js-api'],
silenceDeprecations: ['legacy-js-api', 'import'],
},
styl: {
additionalData: `$injectedColor ?= orange`,