mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-26 11:26:35 +08:00
22 lines
482 B
TypeScript
22 lines
482 B
TypeScript
import { renderSync } from 'sass';
|
|
|
|
// allow to import from node_modules
|
|
// @import "~package-name/var.scss"
|
|
const tildeImporter = (url: string) => {
|
|
if (url.includes('~')) {
|
|
url = url.replace('~', '');
|
|
|
|
if (!url.includes('.scss')) {
|
|
url += '.scss';
|
|
}
|
|
|
|
url = require.resolve(url);
|
|
}
|
|
return { file: url };
|
|
};
|
|
|
|
export async function compileSass(filePath: string) {
|
|
const { css } = renderSync({ file: filePath, importer: tildeImporter });
|
|
return css;
|
|
}
|