Skip to content

Commit

Permalink
feat:优化打包命令。
Browse files Browse the repository at this point in the history
  • Loading branch information
OXOYO committed Jun 25, 2020
1 parent ba69631 commit 765eb2d
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 23 deletions.
1 change: 1 addition & 0 deletions .env.build-lib
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
NODE_ENV = 'build-lib'
1 change: 1 addition & 0 deletions .env.development
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
NODE_ENV = 'development'
1 change: 1 addition & 0 deletions .env.production
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
NODE_ENV = 'production'
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
"description": "A visual graph editor based on G6 and Vue.",
"main": "dist/xfc.umd.min.js",
"scripts": {
"serve": "vue-cli-service serve",
"example": "npx --max_old_space_size=8192 vue-cli-service serve ./example/main.js",
"build": "vue-cli-service build",
"build-package": "vue-cli-service build --target lib --name xfc ./src/xfc.js --dest ./dist --report",
"serve": "vue-cli-service serve --mode development",
"example": "npx --max_old_space_size=4096 vue-cli-service serve --mode development ./example/main.js",
"build": "vue-cli-service build --mode production",
"build-lib": "vue-cli-service build --mode build-lib --target lib --name xfc ./src/xfc.js --dest ./dist --report",
"lint": "vue-cli-service lint"
},
"repository": {
Expand Down
36 changes: 17 additions & 19 deletions vue.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
* 文档:https://cli.vuejs.org/zh/config/
*/

const webpack = require('webpack')

module.exports = {
// 部署应用包时的基本URL,置空使用相对路径
publicPath: '/X-Flowchart-Vue/',
Expand Down Expand Up @@ -48,25 +46,25 @@ module.exports = {
'@antv/g6': 'G6',
'iview': 'iview'
}
}
,
},
chainWebpack: config => {
const cdn = {
// 访问https://unpkg.com/element-ui/lib/theme-chalk/index.css获取最新版本
css: ['//unpkg.com/[email protected]/dist/styles/iview.css'],
js: [
'//unpkg.com/[email protected]/dist/vue.min.js',
'//unpkg.com/[email protected]/dist/vuex.min.js',
'//unpkg.com/[email protected]/dist/iview.js',
'//unpkg.com/@antv/[email protected]/dist/g6.min.js'
]
}
config.when(['development', 'production'].includes(process.env.NODE_ENV), config => {
const cdn = {
css: ['//unpkg.com/[email protected]/dist/styles/iview.css'],
js: [
'//unpkg.com/[email protected]/dist/vue.min.js',
'//unpkg.com/[email protected]/dist/vuex.min.js',
'//unpkg.com/[email protected]/dist/iview.js',
'//unpkg.com/@antv/[email protected]/dist/g6.min.js'
]
}

// 如果使用多页面打包,使用vue inspect --plugins查看html是否在结果数组中
config.plugin('html').tap(args => {
// html中添加cdn
args[0].cdn = cdn
return args
// 如果使用多页面打包,使用vue inspect --plugins查看html是否在结果数组中
config.plugin('html').tap(args => {
// html中添加cdn
args[0].cdn = cdn
return args
})
})
}
}

0 comments on commit 765eb2d

Please sign in to comment.