From a01ad99b00ff7ce5a3d930b7be005af821540fe8 Mon Sep 17 00:00:00 2001 From: ioslh Date: Wed, 30 Jun 2021 14:51:14 +0800 Subject: [PATCH] chore(deploy): use prod vue for prod bundle (#2389) --- website/webpack.config.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/website/webpack.config.js b/website/webpack.config.js index aee7752646..b9ef4daa64 100644 --- a/website/webpack.config.js +++ b/website/webpack.config.js @@ -9,6 +9,12 @@ const CssMinimizerPlugin = require('css-minimizer-webpack-plugin') // const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin const isProd = process.env.NODE_ENV === 'production' + +/* + * 是否使用生产环境的 vue + */ +const isVueProd = process.env.VUE_BUNDLE === 'production' || isProd +const vueBundle = isVueProd ? 'vue.esm-browser.prod.js' : 'vue.esm-browser.js' const isPlay = !!process.env.PLAY_ENV const config = { @@ -63,7 +69,7 @@ const config = { resolve: { extensions: ['.ts', '.tsx', '.js', '.vue', '.json'], alias: { - vue: 'vue/dist/vue.esm-browser.js', + vue: `vue/dist/${vueBundle}`, examples: path.resolve(__dirname), }, }, @@ -78,7 +84,9 @@ const config = { ], devServer: { inline: true, - hot: true, + // 如果使用 vue 的生产环境构建包,无法启用 hmr + // 因为生产环境下 vue 没有注入 hmr 必须的 __VUE_HMR_RUNTIME__ api + hot: !isVueProd, stats: 'minimal', publicPath: '/', contentBase: __dirname,