fix(@vant/cli): compile sass tilde failed (#10144)

This commit is contained in:
neverland 2022-01-04 20:34:24 +08:00 committed by GitHub
parent f63ea390b6
commit 18921e2d1d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,5 +1,7 @@
import { createRequire } from 'module';
const require = createRequire(import.meta.url);
// allow to import from node_modules
// @import "~package-name/var.scss"
const tildeImporter = (url: string) => {
@ -16,7 +18,6 @@ const tildeImporter = (url: string) => {
};
export async function compileSass(filePath: string) {
const require = createRequire(import.meta.url);
const { renderSync } = require('sass');
const { css } = renderSync({ file: filePath, importer: tildeImporter });
return css;