-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathvue.config.js
109 lines (105 loc) · 3.78 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
const webpack = require('webpack');
const path = require('path');
const MonacoWebpackPlugin = require('monaco-editor-webpack-plugin');
// const ExtractTextPlugin = require('extract-text-webpack-plugin');
module.exports = {
devServer: {
disableHostCheck: true
},
runtimeCompiler: true,
chainWebpack(config) {
// 换肤loader[scss]
const scss = config.module.rule('scss').toConfig();
const useable_scss = { ...scss.oneOf[3], test: /\.lazy\.scss$/ };
useable_scss.use = [...useable_scss.use];
useable_scss.use[0] = { loader: 'style-loader', options: { injectType: 'lazySingletonStyleTag' } };
config.module.rule('scss').merge({
oneOf: [useable_scss]
});
// 换肤loader[less]
const less = config.module.rule('less').toConfig();
const useable_less = { ...less.oneOf[3], test: /\.lazy\.less$/ };
useable_less.use = [...useable_less.use];
useable_less.use[0] = { loader: 'style-loader', options: { injectType: 'lazySingletonStyleTag' } };
config.module.rule('less').merge({
oneOf: [useable_less]
});
},
configureWebpack: {
module: {
rules: [
{
test: /\.ts?$/,
loader: 'assemblyscript-typescript-loader',
include: /assembly/, //to avoid a conflict with other ts file who use 'ts-load',so you can division them with prop 'include'
options: {
limit: 1000,
name: `static/assembly/[name].[hash:8].wasm`
}
}
]
},
resolve: {
alias: {
'@ant-design/icons/lib/dist$': path.resolve(__dirname, './src/config/icons.ts')
}
},
plugins: [
new webpack.ContextReplacementPlugin(/moment[/\\]locale$/, /zh-cn|jp/),
new MonacoWebpackPlugin({
languages: ['javascript', 'typescript', 'css', 'scss', 'html', 'json', 'csharp']
})
// new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/)
],
optimization: {
splitChunks: {
chunks: 'all',
cacheGroups: {
libs: {
name: 'chunk-libs',
test: /[\\/]node_modules[\\/]/,
priority: 10,
chunks: 'initial' // only package third parties that are initially dependent
},
elementUI: {
name: 'chunk-antDesign',
priority: 20, // the weight needs to be larger than libs and app or it will be packaged into libs or app
test: /[\\/]node_modules[\\/]_?ant-design-vue(.*)/ // in order to adapt to cnpm
},
commons: {
name: 'chunk-commons',
test: path.resolve(__dirname, './src/components'),
minChunks: 3,
priority: 5,
reuseExistingChunk: true
}
}
}
}
},
css: {
sourceMap: process.env.NODE_ENV !== 'production',
requireModuleExtension: true,
loaderOptions: {
less: {
javascriptEnabled: true
},
scss: {
prependData: `@import "~@/assets/scss/variables.scss";`
}
}
},
pwa: {
name: 'demo',
msTileColor: '#42B983'
},
pluginOptions: {
webpackBundleAnalyzer: {
openAnalyzer: false
},
apollo: {
enableMocks: true,
enableEngine: true
}
}
};