diff --git a/.env.develop b/.env.develop index d417d769..c8349cd4 100644 --- a/.env.develop +++ b/.env.develop @@ -1 +1,2 @@ +ENV=develop VITE_APP_BASE_API=/api \ No newline at end of file diff --git a/.env.production b/.env.production index d417d769..990e0635 100644 --- a/.env.production +++ b/.env.production @@ -1 +1,2 @@ +ENV=production VITE_APP_BASE_API=/api \ No newline at end of file diff --git a/plugin/optimize.ts b/plugin/optimize.ts new file mode 100644 index 00000000..75e6721b --- /dev/null +++ b/plugin/optimize.ts @@ -0,0 +1,49 @@ +import fs from 'fs' +import path from 'path' + +const rootPath = path.resolve(__dirname, '../') + +function optimizeAntdComponents(moduleName: string): string[] { + const moduleESPath = `${moduleName}/es` + const nodeModulePath = `./node_modules/${moduleESPath}` + const includes: string[] = [moduleESPath] + + const folders = fs.readdirSync( + path.resolve(rootPath, nodeModulePath) + ) + + folders.map(name => { + const folderName = path.resolve( + rootPath, + nodeModulePath, + name + ) + let stat = fs.lstatSync(folderName) + if (stat.isDirectory()) { + let styleFolder = path.resolve(folderName, 'style') + if (fs.existsSync((styleFolder))) { + let _stat = fs.lstatSync(styleFolder) + if (_stat.isDirectory()) { + includes.push(`${moduleESPath}/${name}/style`) + } + } + } + }) + + return includes +} + +export function optimizeDeps() { + return { + name: "optimizeDeps", + configResolved: async (config) => { + const components = [ + ...optimizeAntdComponents('ant-design-vue'), + ...optimizeAntdComponents('jetlinks-ui-components') + ] + let concat = config.optimizeDeps.include.concat(components) + config.optimizeDeps.include = Array.from(new Set(concat)) + console.log(config.optimizeDeps.include) + } + } +} \ No newline at end of file diff --git a/src/App.vue b/src/App.vue index 02bc5677..b61b8ee9 100644 --- a/src/App.vue +++ b/src/App.vue @@ -1,8 +1,13 @@ diff --git a/src/views/rule-engine/Alarm/Configuration/index.vue b/src/views/rule-engine/Alarm/Configuration/index.vue index 37b034fc..7caf7701 100644 --- a/src/views/rule-engine/Alarm/Configuration/index.vue +++ b/src/views/rule-engine/Alarm/Configuration/index.vue @@ -80,10 +80,6 @@