2020-06-16 07:20:27 +00:00
|
|
|
|
module.exports = {
|
|
|
|
|
devServer: {
|
|
|
|
|
port: 8887,
|
|
|
|
|
open: true
|
2020-06-30 08:53:01 +00:00
|
|
|
|
},
|
2020-07-02 02:37:43 +00:00
|
|
|
|
|
|
|
|
|
// webpack 设置 详见 https://cli.vuejs.org/zh/guide/webpack.html vue的webpack设置
|
2020-06-30 08:53:01 +00:00
|
|
|
|
chainWebpack: config => {
|
2020-07-02 02:37:43 +00:00
|
|
|
|
// 设置线上环境(打包)的main.js
|
2020-06-30 08:53:01 +00:00
|
|
|
|
config.when(process.env.NODE_ENV === 'production', config => {
|
|
|
|
|
config.entry('app').clear().add('./src/main-prod.js')
|
2020-07-02 02:37:43 +00:00
|
|
|
|
// 使用如下对象时,先去window对象中查找,也就是不node_modules中打包,但需要在public/index.html中自行引入外部资源
|
|
|
|
|
config.set('externals', {
|
|
|
|
|
vue: 'Vue',
|
|
|
|
|
'element-ui': 'Element',
|
|
|
|
|
'vue-router': 'VueRouter',
|
|
|
|
|
axios: 'axios',
|
|
|
|
|
lodash: '_',
|
|
|
|
|
echarts: 'echarts',
|
|
|
|
|
nprogress: 'NProgress',
|
|
|
|
|
'vue-quill-editor': 'VueQuillEditor'
|
|
|
|
|
})
|
2020-07-02 02:53:26 +00:00
|
|
|
|
|
|
|
|
|
config.plugin('html').tap(args => {
|
|
|
|
|
args[0].isProd = true
|
|
|
|
|
return args
|
|
|
|
|
})
|
2020-06-30 08:53:01 +00:00
|
|
|
|
})
|
2020-07-02 02:37:43 +00:00
|
|
|
|
// 设置开发环境的main.js
|
2020-06-30 08:53:01 +00:00
|
|
|
|
config.when(process.env.NODE_ENV === 'development', config => {
|
|
|
|
|
config.entry('add').clear().add('./src/main-dev.js')
|
2020-07-02 02:53:26 +00:00
|
|
|
|
|
|
|
|
|
config.plugin('html').tap(args => {
|
|
|
|
|
args[0].isProd = false
|
|
|
|
|
return args
|
|
|
|
|
})
|
2020-06-30 08:53:01 +00:00
|
|
|
|
})
|
2020-06-16 02:20:06 +00:00
|
|
|
|
}
|
|
|
|
|
}
|