2 Star 0 Fork 0

BeginnerVue / Beginner_Vue_Shop

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
vue.config.js 1.66 KB
一键复制 编辑 原始数据 按行查看 历史
// 条件执行一个函数去继续配置
// condition: Boolean
// whenTruthy: Function -> ChainedMap, 当条件为真,调用把ChainedMap实例作为单一参数传入的函数
// whenFalsy: Optional Function -> ChainedMap, 当条件为假,调用把ChainedMap实例作为单一参数传入的函数
// when(condition, whenTruthy, whenFalsy)
// https://github.com/Yatoo2018/webpack-chain/tree/zh-cmn-Hans
module.exports = {
chainWebpack: config => {
// 发布模式
config.when(process.env.NODE_ENV === 'production',
config => {
config// 修改 entry 配置
.entry('app').clear()
.add('./src/main-prod.js')
.end()
// 通过 externals 加载外部 CDN 资源
// 此处设置了 externals 对象, webpack 打包时候不会将下面声明的对象合并到输出的文件中,而是直接去window全局查找并直接使用
config.set('externals', {
vue: 'Vue',
'vue-router': 'VueRouter',
axios: 'axios',
lodash: '_',
echarts: 'echarts',
nprogress: 'NProgress',
'vue-quill-editor': 'VueQuillEditor'
})
config.plugin('html').tap(args => {
// 挂载 isProd 参数在index.html页面中使用
args[0].isProd = true
return args
})
}
)
// 开发模式
config.when(process.env.NODE_ENV === 'development',
config => {
config// 修改 entry 配置
.entry('app').clear()
.add('./src/main-dev.js')
.end()
config.plugin('html').tap(args => {
args[0].isProd = false
return args
})
}
)
},
}
1
https://gitee.com/beginner-vue/beginner_vue_shop.git
git@gitee.com:beginner-vue/beginner_vue_shop.git
beginner-vue
beginner_vue_shop
Beginner_Vue_Shop
master

搜索帮助