-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathvue.config.js
68 lines (59 loc) · 1.63 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
const glob = require('glob');
const path = require('path');
const BundleTracker = require('webpack-bundle-tracker');
const pages = glob.sync("*/vue/*.js").reduce((memo, file) => {
memo[path.parse(file).name] = {
entry: file,
chunks: ['vendor'],
};
return memo
}, {});
const devHost = 'localhost';
const devPort = 9000;
const devMode = process.env.NODE_ENV !== 'production';
module.exports = {
pages,
filenameHashing: false,
productionSourceMap: false,
publicPath: devMode ? `http://${devHost}:${devPort}/` : '',
outputDir: 'static/vue/',
chainWebpack: config => {
if (devMode) {
config.devtool('source-map');
}
config.optimization
.splitChunks({
cacheGroups: {
vendor: {
test: /[\\/]node_modules[\\/]/,
name: 'vendor',
chunks: 'all',
priority: 1,
},
},
});
// Django is serving webpack bundles via its template engine; disable
// Vue's automatic generation of HTML.
Object.keys(pages).forEach(page => {
config.plugins.delete(`html-${page}`);
config.plugins.delete(`preload-${page}`);
config.plugins.delete(`prefetch-${page}`);
});
config
.plugin('BundleTracker')
.use(BundleTracker, [{
path: '/project',
filename: 'webpack-stats.json'
}]);
config.resolve.alias
.set('__STATIC__', 'static');
config.devServer
.public(`http://${devHost}:${devPort}`)
.host('0.0.0.0')
.port(devPort)
.hotOnly(true)
.watchOptions({poll: 1000})
.https(false)
.headers({'Access-Control-Allow-Origin': ['*']});
}
};