mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
feat(cli): support sass tilde importer
This commit is contained in:
parent
f457ae3c87
commit
3f0f3e4474
@ -1,6 +1,21 @@
|
||||
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 });
|
||||
const { css } = renderSync({ file: filePath, importer: tildeImporter });
|
||||
return css;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user