From b53dc23c19785cfa6da134e057eb15efcda0a8e2 Mon Sep 17 00:00:00 2001 From: zhangyuxiang Date: Thu, 2 Mar 2023 10:06:15 +0800 Subject: [PATCH 1/2] =?UTF-8?q?perf:=20=E5=8E=BB=E9=99=A4=E6=89=93?= =?UTF-8?q?=E5=8C=85=E6=97=A0=E7=94=A8=E7=9A=84=E4=B8=89=E6=96=B9=E5=BA=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- vue.config.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/vue.config.js b/vue.config.js index ba37f0c..04693be 100644 --- a/vue.config.js +++ b/vue.config.js @@ -12,6 +12,16 @@ module.exports = { filename: 'index.html' } }, + externals: { + vue: { + root: 'Vue', + commonjs: 'vue', + commonjs2: 'vue', + amd: 'vue' + }, + 'element-plus': 'element-plus', + 'vue-router': 'vue-router' + }, // 强制内联CSS css: { extract: false -- Gitee From 437af4ffde933336421c21886ae0f922a8ae85cb Mon Sep 17 00:00:00 2001 From: zhangyuxiang Date: Fri, 3 Mar 2023 15:04:34 +0800 Subject: [PATCH 2/2] =?UTF-8?q?fix:=20=E5=BD=93=E6=89=93=E5=8C=85=E6=A8=A1?= =?UTF-8?q?=E5=BC=8F=E4=B8=BA=E7=B1=BB=E5=BA=93=E6=97=B6=EF=BC=8C=E6=89=8D?= =?UTF-8?q?=E9=9C=80=E8=A6=81=E6=8E=92=E9=99=A4=E4=BB=A5=E4=B8=8B=E7=AC=AC?= =?UTF-8?q?=E4=B8=89=E6=96=B9=E5=BA=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env.buildExp | 2 ++ package.json | 2 +- vue.config.js | 23 ++++++++++++++--------- 3 files changed, 17 insertions(+), 10 deletions(-) create mode 100644 .env.buildExp diff --git a/.env.buildExp b/.env.buildExp new file mode 100644 index 0000000..13eb909 --- /dev/null +++ b/.env.buildExp @@ -0,0 +1,2 @@ +NODE_ENV='production' +VUE_APP_BUILD='lib' diff --git a/package.json b/package.json index 43681cd..f349a45 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "private": false, "main": "lib/SnakerflowDesigner.umd.min.js", "scripts": { - "lib": "vue-cli-service build --target lib --name SnakerflowDesigner --dest lib packages/index.ts", + "lib": "vue-cli-service build --mode buildLib --target lib --name SnakerflowDesigner --dest lib packages/index.ts", "dev": "vue-cli-service serve", "serve": "vue-cli-service serve", "build": "vue-cli-service build", diff --git a/vue.config.js b/vue.config.js index 04693be..f0a3908 100644 --- a/vue.config.js +++ b/vue.config.js @@ -12,15 +12,20 @@ module.exports = { filename: 'index.html' } }, - externals: { - vue: { - root: 'Vue', - commonjs: 'vue', - commonjs2: 'vue', - amd: 'vue' - }, - 'element-plus': 'element-plus', - 'vue-router': 'vue-router' + configureWebpack: config => { + // 当打包模式为类库时,需要排除以下第三方库 + if (process.env.VUE_APP_BUILD === 'lib') { + config.externals = { + vue: { + root: 'Vue', + commonjs: 'vue', + commonjs2: 'vue', + amd: 'vue' + }, + 'element-plus': 'element-plus', + 'vue-router': 'vue-router' + } + } }, // 强制内联CSS css: { -- Gitee