-
Notifications
You must be signed in to change notification settings - Fork 0
/
vue.config.js
129 lines (107 loc) · 3.1 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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
const path = require('path')
const fs = require('fs')
const pathApp = process.env.INIT_CWD
const pathAppConfig = path.join(pathApp, 'vue2-bootstrap.js')
const appConfig = require(pathAppConfig)
const vueConfig = {
publicPath: appConfig.publicPath || undefined,
outputDir: path.resolve(pathApp, appConfig.outputDir),
runtimeCompiler: true,
productionSourceMap: process.env.NODE_ENV !== 'production',
filenameHashing: appConfig.filenameHashing === true || false,
transpileDependencies: [
...appConfig.transpileDependencies
],
devServer: {
allowedHosts: 'all',
webSocketServer: {
type: 'sockjs',
options: {
path: appConfig.sockPath || undefined
}
},
client: {
webSocketTransport: 'sockjs',
webSocketURL: {
hostname: '0.0.0.0',
port: 443,
pathname: appConfig.sockPath || undefined
}
}
},
configureWebpack: {
devtool: appConfig.devtool,
plugins: [
...appConfig.plugins
],
resolve: {
// do not resolve to orig of linked sources
// e.g. linked @afeefa/shared-js-lib
symlinks: false,
alias: {
// prevent multiple instances of vue
// https://github.com/webpack/webpack/issues/2134#issuecomment-192579511
// and https://github.com/vuetifyjs/vuetify/issues/4068
vue: path.resolve(pathApp, 'node_modules', 'vue'),
'@': path.resolve(pathApp, 'src'),
...appConfig.aliases
},
extensions: ['.js', '.vue', '.json']
}
},
chainWebpack: config => {
const pathIndex = path.resolve(pathApp, 'public', 'index.html')
if (fs.existsSync(pathIndex)) {
// use projects public/index.html
const htmlPlugin = config.plugins.get('html')
if (htmlPlugin) {
config
.plugin('html')
.tap(args => {
args[0].template = path.resolve(pathApp, 'public', 'index.html')
return args
})
}
}
if (!appConfig.splitChunks) {
config.optimization.delete('splitChunks')
}
// https://github.com/webpack/webpack-dev-server/issues/3453#issuecomment-863630905
// webpack caches all node_module folder otherwise
config.merge({
snapshot: {
managedPaths: []
}
})
},
css: {
extract: appConfig.extractCss || false,
loaderOptions: {
css: {
// https://webpack.js.org/loaders/css-loader/#url
// allows absolute paths in url() functions
url: {
filter: url => {
return !url.startsWith('/')
}
}
},
// ignore deprecation warnings which e.g. is vuetify full of
// sassLoaderOptions: {
// warnRuleAsWarning: false
// },
sass: {
...appConfig.sassLoaderOptions
},
scss: {
// @/ is an alias to src/
// so this assumes you have a file named `src/variables.scss`
additionalData: appConfig.scssImports
? appConfig.scssImports.map(i => `@import "${i}";`).join(' ')
: undefined
}
}
}
}
// console.log(JSON.stringify(vueConfig, null, 4))
module.exports = vueConfig