forked from ymm-tech/gods-pen
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvue.config.js
95 lines (90 loc) · 2.33 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
const path = require('path')
const MonacoWebpackPlugin = require('monaco-editor-webpack-plugin')
const config = require('./src/config/index')
let page
switch (process.env.PAGE) {
case 'CLIENT':
page = {
entry: 'src/client.js',
template: 'src/client.tpl',
outputDir: `dist/${config.VIEW_NAME || 'view'}`,
publicPath: '/' + config.VIEW_NAME,
port: 8566,
}
break
case 'EDITOR':
default:
page = {
entry: 'src/editor.js',
template: 'src/editor.tpl',
outputDir: `dist/${config.EDITOR_NAME || 'editor'}`,
publicPath: '/' + config.EDITOR_NAME,
title: config.EDITOR_TITLE,
port: 8565,
externals: {
'plupload': 'plupload',
},
alias: {
'onigasm.wasm': path.join(__dirname, './node_modules/onigasm/lib/onigasm.wasm'),
},
plugins: [new MonacoWebpackPlugin()]
}
}
const configureWebpack = {
resolve: {
alias: Object.assign({
'src': path.join(__dirname, 'src')
}, page.alias || {})
},
externals: Object.assign({
'FastClick': 'FastClick',
'html2canvas': 'html2canvas'
}, page.externals || {}),
plugins: page.plugins || []
}
if (process.env.NODE_ENV === 'production') {
configureWebpack.externals.vue = 'Vue'
configureWebpack.externals['vue-router'] = 'VueRouter'
configureWebpack.externals.vuex = 'Vuex'
}
module.exports = {
publicPath: page.publicPath,
assetsDir: 'static',
outputDir: page.outputDir,
lintOnSave: process.env.NODE_ENV !== 'production',
productionSourceMap: process.env.NODE_ENV !== 'production',
pages: {
index: {
filename: 'index.html',
entry: page.entry,
template: page.template,
title: page.title,
hmid: config.BAIDU_TONGJI
}
},
devServer: {
disableHostCheck: true,
port: page.port,
publicPath: '/',
historyApiFallback: true
},
configureWebpack: configureWebpack,
chainWebpack: config => {
config.plugins.delete('preload-index')
config.plugins.delete('prefetch-index')
config.plugin('define').tap(args => {
args[0]['process.env'].CODE_ENV = JSON.stringify(process.env.CODE_ENV)
return args
})
config.module
.rule('wasm')
.test(/\.wasm$/)
.use('file-loader')
.loader('file-loader')
.tap(options => {
return {
limit: 0
}
})
}
}