|
@@ -15,28 +15,28 @@ module.exports = {
|
15
|
15
|
* WebpackChain 插件配置
|
16
|
16
|
* @docs https:
|
17
|
17
|
*/
|
18
|
|
-
|
19
|
|
-
|
20
|
|
-
|
21
|
|
-
|
22
|
|
-
|
23
|
|
-
|
24
|
|
-
|
|
18
|
+ webpackChain (chain) {
|
|
19
|
+
|
|
20
|
+ * 如果 h5 端编译后体积过大,可以使用 webpack-bundle-analyzer 插件对打包体积进行分析。
|
|
21
|
+ * @docs https:
|
|
22
|
+ */
|
|
23
|
+ chain.plugin('analyzer')
|
|
24
|
+ .use(require('webpack-bundle-analyzer').BundleAnalyzerPlugin, [])
|
25
|
25
|
|
26
|
|
-
|
27
|
|
-
|
28
|
|
-
|
29
|
|
-
|
30
|
|
-
|
31
|
|
-
|
32
|
|
-
|
33
|
|
-
|
34
|
|
-
|
35
|
|
-
|
36
|
|
-
|
37
|
|
-
|
38
|
|
-
|
39
|
|
-
|
40
|
|
-
|
|
26
|
+
|
|
27
|
+ * 如果 h5 端首屏加载时间过长,可以使用 prerender-spa-plugin 插件预加载首页。
|
|
28
|
+ * @docs https:
|
|
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
|
}
|