vue-cli2 打包全配置
//将vue 全部打包分离出去
//减小limit 过大的图片不去打包成base64
webpack.base
module.exports = {
externals: {
'vue':'Vue',
'vue-router':'VueRouter',
'vuex':'Vuex',
'element-ui':'ELEMENT'
},
module: {
rules: [
{
test: /\.(png|jpe?g|gif|svg)(\?.*)?$/,
loader: 'url-loader',
options: {
limit: 1000,
name: utils.assetsPath('img/[name].[hash:7].[ext]')
}
}}
}
utils
if (options.extract) {
return ExtractTextPlugin.extract({
use: loaders,
fallback: 'vue-style-loader',
publicPath:'../../' //背景图片路径问题
})
}
webpack.prod
output: {
publicPath:'./',//解决文件路径问题
},
index
dev: {
// Paths
assetsSubDirectory: 'static',
assetsPublicPath: './', //打包空白 相对路径 打包用的绝对路径
proxyTable: {
'/apis':{
target:'http://x.x.x.x',//默认域名
changeOrigin:true, //开启跨域
// secure:false,//https true是开启不校验
pathRewrite:{
'^/apis':'/leite' //替换包名 如果target 有包名会报错
}
}
},
// Various Dev Server settings
host: '0.0.0.0' //局域网访问
main
Vue.config.productionTip = false //取消启动提示
Vue.config.devtools = false //取消检测代码
Vue.config.silent = true //取消 Vue 所有的日志与警告。