vue-learn/vue.config.js

30 lines
984 B
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

module.exports = {
devServer: {
port: 8887,
open: true
},
// webpack 设置 详见 https://cli.vuejs.org/zh/guide/webpack.html vue的webpack设置
chainWebpack: config => {
// 设置线上环境打包的main.js
config.when(process.env.NODE_ENV === 'production', config => {
config.entry('app').clear().add('./src/main-prod.js')
// 使用如下对象时先去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'
})
})
// 设置开发环境的main.js
config.when(process.env.NODE_ENV === 'development', config => {
config.entry('add').clear().add('./src/main-dev.js')
})
}
}