-
Notifications
You must be signed in to change notification settings - Fork 8
/
vue.config.js
107 lines (102 loc) · 3.19 KB
/
vue.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
const path = require('path')
const packageInfo = require('./package.json')
const isProd = process.env.NODE_ENV === 'production'
const isBuildLib = (process.env.npm_lifecycle_script || '').includes('--target lib')
const { defineConfig } = require('@vue/cli-service')
const sass = require('sass')
function resolve(dir) {
return path.join(__dirname, dir)
}
function getDevPackageVersion(packageName) {
const version = packageInfo.devDependencies[packageName]
return version[0] === '^' ? version.slice(1) : version
}
function createExamplePage(folder) {
const Vue = getDevPackageVersion('vue')
const VueRouter = getDevPackageVersion('vue-router')
const Vuex = getDevPackageVersion('vuex')
const ElementUI = getDevPackageVersion('element-ui')
return {
entry: `example/${folder}/main.js`,
cdn: {
css: [
`https://cdnjs.cloudflare.com/ajax/libs/element-ui/${ElementUI}/theme-chalk/index.min.css`
],
js: isProd
? [
`https://cdnjs.cloudflare.com/ajax/libs/vue/${Vue}/vue.min.js`,
`https://cdnjs.cloudflare.com/ajax/libs/vuex/${Vuex}/vuex.min.js`,
`https://cdnjs.cloudflare.com/ajax/libs/vue-router/${VueRouter}/vue-router.min.js`,
`https://cdnjs.cloudflare.com/ajax/libs/element-ui/${ElementUI}/index.min.js`
]
: []
}
}
}
module.exports = defineConfig({
publicPath: isProd ? '/el-admin-layout/' : '/',
outputDir: isBuildLib ? 'dist' : 'dist/example',
assetsDir: 'static',
productionSourceMap: false,
pages: {
'index': createExamplePage('复杂功能'),
'base-use': createExamplePage('基础使用'),
'async-load-menu': createExamplePage('从服务器加载菜单'),
'custom-menu': createExamplePage('自定义menu'),
'custom-hamburger-position': createExamplePage('自定义汉堡包位置'),
'custom-page-header': createExamplePage('自定义页头'),
'custom-page-footer': createExamplePage('自定义页脚'),
'aside-search': createExamplePage('侧边栏搜索框'),
'simulate-mobile': createExamplePage('模拟移动端'),
'setting-drawer': createExamplePage('设置抽屉'),
'persist-tags': createExamplePage('持久化页签'),
'old-qiniu-aside': createExamplePage('仿旧版七牛云侧边栏'),
'chrome-tabs': createExamplePage('仿chrome页签')
},
css: {
loaderOptions: {
sass: {
sassOptions: {
logger: sass.Logger.silent
}
}
}
},
configureWebpack: {
name: packageInfo.name,
resolve: {
alias: {
'@example': resolve('example'),
'el-admin-layout': resolve('')
}
},
externals: isProd
? {
'vue': 'Vue',
'vuex': 'Vuex',
'vue-router': 'VueRouter',
'element-ui': 'ELEMENT'
}
: {},
devServer: {
port: 8079,
client: {
overlay: false,
progress: true
},
historyApiFallback: false
}
},
chainWebpack: config => {
if (isBuildLib) {
config.output.library('ElAdminLayout')
}
/*else {
config.plugin('html-index').tap((args) => {
args[0].scriptLoading = 'blocking'
args[0].publicPath = 'auto'
return args
})
}*/
}
})