|
@@ -15,28 +15,28 @@ module.exports = {
|
15
|
15
|
* WebpackChain 插件配置
|
16
|
16
|
* @docs https://github.com/neutrinojs/webpack-chain
|
17
|
17
|
*/
|
18
|
|
- // webpackChain (chain) {
|
19
|
|
- // /**
|
20
|
|
- // * 如果 h5 端编译后体积过大,可以使用 webpack-bundle-analyzer 插件对打包体积进行分析。
|
21
|
|
- // * @docs https://github.com/webpack-contrib/webpack-bundle-analyzer
|
22
|
|
- // */
|
23
|
|
- // chain.plugin('analyzer')
|
24
|
|
- // .use(require('webpack-bundle-analyzer').BundleAnalyzerPlugin, [])
|
|
18
|
+ webpackChain (chain) {
|
|
19
|
+ /**
|
|
20
|
+ * 如果 h5 端编译后体积过大,可以使用 webpack-bundle-analyzer 插件对打包体积进行分析。
|
|
21
|
+ * @docs https://github.com/webpack-contrib/webpack-bundle-analyzer
|
|
22
|
+ */
|
|
23
|
+ chain.plugin('analyzer')
|
|
24
|
+ .use(require('webpack-bundle-analyzer').BundleAnalyzerPlugin, [])
|
25
|
25
|
|
26
|
|
- // /**
|
27
|
|
- // * 如果 h5 端首屏加载时间过长,可以使用 prerender-spa-plugin 插件预加载首页。
|
28
|
|
- // * @docs https://github.com/chrisvfritz/prerender-spa-plugin
|
29
|
|
- // */
|
30
|
|
- // const path = require('path')
|
31
|
|
- // const Prerender = require('prerender-spa-plugin')
|
32
|
|
- // const staticDir = path.join(__dirname, '..', 'dist')
|
33
|
|
- // chain
|
34
|
|
- // .plugin('prerender')
|
35
|
|
- // .use(new Prerender({
|
36
|
|
- // staticDir,
|
37
|
|
- // routes: [ '/pages/index/index' ],
|
38
|
|
- // postProcess: (context) => ({ ...context, outputPath: path.join(staticDir, 'index.html') })
|
39
|
|
- // }))
|
40
|
|
- // }
|
|
26
|
+ /**
|
|
27
|
+ * 如果 h5 端首屏加载时间过长,可以使用 prerender-spa-plugin 插件预加载首页。
|
|
28
|
+ * @docs https://github.com/chrisvfritz/prerender-spa-plugin
|
|
29
|
+ */
|
|
30
|
+ const path = require('path')
|
|
31
|
+ const Prerender = require('prerender-spa-plugin')
|
|
32
|
+ const staticDir = path.join(__dirname, '..', 'dist')
|
|
33
|
+ chain
|
|
34
|
+ .plugin('prerender')
|
|
35
|
+ .use(new Prerender({
|
|
36
|
+ staticDir,
|
|
37
|
+ routes: [ '/pages/index/index' ],
|
|
38
|
+ postProcess: (context) => ({ ...context, outputPath: path.join(staticDir, 'index.html') })
|
|
39
|
+ }))
|
|
40
|
+ }
|
41
|
41
|
}
|
42
|
42
|
}
|