-
Notifications
You must be signed in to change notification settings - Fork 119
/
vue.config.js
118 lines (113 loc) · 4.14 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
const path = require('path');
const webpack = require('webpack')
const PreloadPlugin = require('@vue/preload-webpack-plugin')
function resolve(dir) {
return path.join(__dirname, dir);
}
module.exports = {
devServer: {
allowedHosts: 'all',
port: 8013
},
publicPath: '/',
outputDir: 'dist',
//assetsDir: 'static',
lintOnSave: process.env.NODE_ENV === 'development',
productionSourceMap: false,
configureWebpack: {
// provide the app's title in webpack's name field, so that
// it can be accessed in index.html to inject the correct title.
resolve: {
alias: {
'@': resolve('src'),
},
fallback: {
'path': false,
'fs': false,
"assert": false,
//"assert": require.resolve("assert/")
"util": false,
//"util": require.resolve("util/")
"os": false,
//"os": require.resolve("os-browserify/browser")
"crypto": false,
//"crypto": require.resolve("crypto-browserify")
"buffer": require.resolve("buffer/")
}
},
plugins: [
new webpack.ProvidePlugin({
process: 'process/browser',
Buffer: ['buffer', 'Buffer']
})],
},
chainWebpack(config) {
// config.plugin('preload').use(PreloadPlugin).tap(() => [
// {
// rel: 'preload',
// // to ignore runtime.js
// // https://github.com/vuejs/vue-cli/blob/dev/packages/@vue/cli-service/lib/config/app.js#L171
// fileBlacklist: [/\.map$/, /hot-update\.js$/, /runtime\..*\.js$/],
// include: 'initial'
// }
// ]);
config.plugins.delete('prefetch');
config.when(process.env.NODE_ENV !== 'development', config => {
config.optimization.splitChunks({
chunks: 'all',
cacheGroups: {
libs: {
name: 'chunk-libs',
test: /[\\/]node_modules[\\/]/,
priority: 10,
chunks: 'initial' // only package third parties that are initially dependent
},
commons: {
name: 'chunk-commons',
test: resolve('src/components'), // can customize your rules
minChunks: 3, // minimum common number
priority: 5,
reuseExistingChunk: true
}
}
});
// https:// webpack.js.org/configuration/optimization/#optimizationruntimechunk
config.optimization.runtimeChunk('single');
});
config.optimization.runtimeChunk('single');
// // 注入全局sacc变量
// const oneOfsMap = config.module.rule('scss').oneOfs.store;
// oneOfsMap.forEach(item => {
// item
// .use('sass-resources-loader')
// .loader('sass-resources-loader')
// .options({
// resources: './src/stylesheet/variables.scss'
// })
// .end();
// });
// config.resolve.alias.set('vue', '@vue/compat')
config.module
.rule("vue")
.use("vue-loader")
.loader("vue-loader")
.tap(options => {
// TODO
// options.compilerOptions.directives = {
// html(node, directiveMeta) {
// (node.props || (node.props = [])).push({
// name: "innerHTML",
// value: `xss(_s(${directiveMeta.value}), xssOptions())`
// });
// }
// };
options.compilerOptions = {
compatConfig: {
//MODE: 2
MODE: 3
}
}
return options;
});
}
};