mirror of
https://github.com/vbenjs/vue-vben-admin.git
synced 2025-08-25 16:16:20 +08:00
fix: fixed svg icon load failure and enabled global injection bem.scss
This commit is contained in:
@@ -22,7 +22,7 @@
|
||||
"types": "./dist/index.d.ts",
|
||||
"exports": {
|
||||
".": {
|
||||
"types": "./dist/index.d.ts",
|
||||
"types": "./src/index.ts",
|
||||
"default": "./dist/index.mjs"
|
||||
}
|
||||
},
|
||||
|
@@ -2,6 +2,10 @@ import type { UserConfig } from 'vite';
|
||||
|
||||
import type { DefineApplicationOptions } from '../typing';
|
||||
|
||||
import { relative } from 'node:path';
|
||||
|
||||
import { findMonorepoRoot } from '@vben/node-utils';
|
||||
|
||||
import { defineConfig, loadEnv, mergeConfig } from 'vite';
|
||||
|
||||
import { loadApplicationPlugins } from '../plugins';
|
||||
@@ -33,6 +37,8 @@ function defineApplicationConfig(userConfigPromise: DefineApplicationOptions) {
|
||||
...application,
|
||||
});
|
||||
|
||||
const { injectGlobalScss = true } = application;
|
||||
|
||||
const applicationConfig: UserConfig = {
|
||||
build: {
|
||||
rollupOptions: {
|
||||
@@ -44,6 +50,7 @@ function defineApplicationConfig(userConfigPromise: DefineApplicationOptions) {
|
||||
},
|
||||
target: 'es2015',
|
||||
},
|
||||
css: createCssOptions(injectGlobalScss),
|
||||
esbuild: {
|
||||
drop: isBuild
|
||||
? [
|
||||
@@ -71,4 +78,24 @@ function defineApplicationConfig(userConfigPromise: DefineApplicationOptions) {
|
||||
});
|
||||
}
|
||||
|
||||
function createCssOptions(injectGlobalScss = true) {
|
||||
const root = findMonorepoRoot();
|
||||
return {
|
||||
preprocessorOptions: injectGlobalScss
|
||||
? {
|
||||
scss: {
|
||||
additionalData: (content: string, filepath: string) => {
|
||||
const relativePath = relative(root, filepath);
|
||||
// apps下的包注入全局样式
|
||||
if (relativePath.startsWith('apps/')) {
|
||||
return `@import "@vben/styles/global";\n${content}`;
|
||||
}
|
||||
return content;
|
||||
},
|
||||
},
|
||||
}
|
||||
: {},
|
||||
};
|
||||
}
|
||||
|
||||
export { defineApplicationConfig };
|
||||
|
@@ -67,6 +67,8 @@ interface ApplicationPluginOptions extends CommonPluginOptions {
|
||||
importmapOptions?: ImportmapPluginOptions;
|
||||
/** 是否注入app loading */
|
||||
injectAppLoading?: boolean;
|
||||
/** 是否注入全局scss */
|
||||
injectGlobalScss?: boolean;
|
||||
/** 是否注入版权信息 */
|
||||
license?: boolean;
|
||||
/** 是否开启pwa */
|
||||
|
Reference in New Issue
Block a user