MCPcopy Index your code
hub / github.com/pythonstock/stock / chainWebpack

Function chainWebpack

frontend/vue.config.js:55–126  ·  view source on GitHub ↗
(config)

Source from the content-addressed store, hash-verified

53 }
54 },
55 chainWebpack(config) {
56 // it can improve the speed of the first screen, it is recommended to turn on preload
57 config.plugin('preload').tap(() => [
58 {
59 rel: 'preload',
60 // to ignore runtime.js
61 // https://github.com/vuejs/vue-cli/blob/dev/packages/@vue/cli-service/lib/config/app.js#L171
62 fileBlacklist: [/\.map$/, /hot-update\.js$/, /runtime\..*\.js$/],
63 include: 'initial'
64 }
65 ])
66
67 // when there are many pages, it will cause too many meaningless requests
68 config.plugins.delete('prefetch')
69
70 // set svg-sprite-loader
71 config.module
72 .rule('svg')
73 .exclude.add(resolve('src/icons'))
74 .end()
75 config.module
76 .rule('icons')
77 .test(/\.svg$/)
78 .include.add(resolve('src/icons'))
79 .end()
80 .use('svg-sprite-loader')
81 .loader('svg-sprite-loader')
82 .options({
83 symbolId: 'icon-[name]'
84 })
85 .end()
86
87 config
88 .when(process.env.NODE_ENV !== 'development',
89 config => {
90 config
91 .plugin('ScriptExtHtmlWebpackPlugin')
92 .after('html')
93 .use('script-ext-html-webpack-plugin', [{
94 // `runtime` must same as runtimeChunk name. default is `runtime`
95 inline: /runtime\..*\.js$/
96 }])
97 .end()
98 config
99 .optimization.splitChunks({
100 chunks: 'all',
101 cacheGroups: {
102 libs: {
103 name: 'chunk-libs',
104 test: /[\\/]node_modules[\\/]/,
105 priority: 10,
106 chunks: 'initial' // only package third parties that are initially dependent
107 },
108 elementUI: {
109 name: 'chunk-elementUI', // split elementUI into a single package
110 priority: 20, // the weight needs to be larger than libs and app or it will be packaged into libs or app
111 test: /[\\/]node_modules[\\/]_?element-ui(.*)/ // in order to adapt to cnpm
112 },

Callers

nothing calls this directly

Calls 3

resolveFunction · 0.85
optionsMethod · 0.80
addMethod · 0.45

Tested by

no test coverage detected