This repository has been archived by the owner on Feb 22, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 55
/
vue.config.js
92 lines (86 loc) · 2.57 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
const klawSync = require('klaw-sync')
const path = require('path')
const HtmlWebpackPlugin = require('html-webpack-plugin')
// Collect the page's names
const pages = {}
const vues = klawSync('./src/pages', {
nodir: true, traverseAll: true, filter(file) {
return path.extname(file.path) === '.vue'
}
})
const pagesIndex = path.resolve(__dirname, 'src/pages').length
vues.map(vue => {
let filename
if (process.platform !== 'win32') {
filename = vue.path.substring(pagesIndex + 1).replace(/\.vue$/, '.html').replace(/\//g, '-')
} else {
filename = vue.path.substring(pagesIndex + 1).replace(/\.vue$/, '.html').replace(/\\/g, '-')
}
const page = filename.substring(0, filename.lastIndexOf("."))
// console.log(filename)
// console.log(page)
pages[page] = {
entry: vue.path,
template: './public/page.ejs',
filename,
chunks: [page, 'runtime'],
name: page,
minify: {
collapseWhitespace: true,
removeComments: true,
removeRedundantAttributes: true,
removeScriptTypeAttributes: true,
removeStyleLinkTypeAttributes: true,
useShortDoctype: true
}
}
})
module.exports = {
pages,
publicPath: '',
filenameHashing: true,
productionSourceMap: false,
lintOnSave: false,
devServer: {
writeToDisk: file => {
return /index.html$/.test(file) || /config.xml$/.test(file)
}
},
configureWebpack: {
output: {
library: "pageVue",
libraryTarget: "window",
libraryExport: 'default'
},
optimization: {
runtimeChunk: {
name: "runtime"
}
},
plugins: [
new HtmlWebpackPlugin({
template: './public/index.html',
chunks: [],
minify: {
collapseWhitespace: true,
removeComments: true,
removeRedundantAttributes: true,
removeScriptTypeAttributes: true,
removeStyleLinkTypeAttributes: true,
useShortDoctype: true
}
})
],
externals: {
vue: 'Vue'
}
},
chainWebpack(config) {
config.optimization.splitChunks(undefined)
config.plugin('copy')
.tap(args => {
args[0][0].ignore.push(process.env.NODE_ENV === 'development' ? 'vue.min.js' : 'vue.js')
return args
})
}
}