chore(deploy): use prod vue for prod bundle (#2389)

This commit is contained in:
ioslh 2021-06-30 14:51:14 +08:00 committed by GitHub
parent 265a6e4c6d
commit a01ad99b00
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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,