Commit a8d321bc by zhuxichen

chore: update

parent cb5e98f5
import { existsSync, readFileSync } from 'fs';
export default function customLoaderPlugin() {
return {
name: 'custom-loader-plugin',
transform(source, id) {
// 替换路径1
const newPath = id.replace(/\/engines\/(.+?)\//, '/');
if (existsSync(newPath)) {
const result = readFileSync(newPath, 'utf-8');
return {
code: result,
};
}
// 替换路径2
const newPath2 = id.replace(/\/engines\//, '/');
if (existsSync(newPath2)) {
const result = readFileSync(newPath2, 'utf-8');
return {
code: result,
};
}
// 如果没有匹配到,返回原始 source
return source;
},
};
}
......@@ -5,7 +5,8 @@
"vitest.config.*",
"cypress.config.*",
"nightwatch.conf.*",
"playwright.config.*"
"playwright.config.*",
"customLoaderPlugin.ts"
],
"compilerOptions": {
"composite": true,
......
......@@ -4,7 +4,7 @@ import Components from 'unplugin-vue-components/vite';
import AutoImport from 'unplugin-auto-import/vite';
import { AntDesignVueResolver } from 'unplugin-vue-components/resolvers';
import path from 'path';
import fs from 'fs';
import customLoaderPlugin from './customLoaderPlugin';
// 当前主题的存储
let currentTheme: Record<string, string> = {};
......@@ -48,6 +48,7 @@ export default defineConfig(async ({ mode }) => {
resolvers: [AntDesignVueResolver()],
dts: 'src/auto-imports.d.ts',
}),
customLoaderPlugin(),
],
css: {
preprocessorOptions: {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment