mirror of
https://github.com/QwenLM/qwen-code.git
synced 2025-12-19 09:33:53 +00:00
build(vscode-ide-companion): 添加 SCSS 支持
- 在 esbuild.js 中添加 SCSS 文件处理逻辑 - 在 package.json 中添加 sass 依赖 - 新增代码使用 sass 编译 SCSS 文件,并将其注入到页面中
This commit is contained in:
@@ -37,6 +37,7 @@ const esbuildProblemMatcherPlugin = {
|
||||
const cssInjectPlugin = {
|
||||
name: 'css-inject',
|
||||
setup(build) {
|
||||
// Handle CSS files
|
||||
build.onLoad({ filter: /\.css$/ }, async (args) => {
|
||||
const fs = await import('fs');
|
||||
const css = await fs.promises.readFile(args.path, 'utf8');
|
||||
@@ -49,6 +50,23 @@ const cssInjectPlugin = {
|
||||
loader: 'js',
|
||||
};
|
||||
});
|
||||
|
||||
// Handle SCSS files
|
||||
build.onLoad({ filter: /\.scss$/ }, async (args) => {
|
||||
const sass = await import('sass');
|
||||
const result = sass.compile(args.path, {
|
||||
loadPaths: [args.path.substring(0, args.path.lastIndexOf('/'))],
|
||||
});
|
||||
const css = result.css;
|
||||
return {
|
||||
contents: `
|
||||
const style = document.createElement('style');
|
||||
style.textContent = ${JSON.stringify(css)};
|
||||
document.head.appendChild(style);
|
||||
`,
|
||||
loader: 'js',
|
||||
};
|
||||
});
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user