diff --git a/packages/vant-cli/src/compiler/compile-sass.ts b/packages/vant-cli/src/compiler/compile-sass.ts index a24d0ad60..6d853dd4d 100644 --- a/packages/vant-cli/src/compiler/compile-sass.ts +++ b/packages/vant-cli/src/compiler/compile-sass.ts @@ -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;