(vue2.0 案例3.0) 在vue-cli 项目中 需要知道常见的配置 防止入坑
来源:互联网 发布:4g网络优势 编辑:程序博客网 时间:2024/05/04 03:50
一、配置打包后的文件路径
进入config>index.js把assetsPublicPath:'/'改成'./';
build: { env: require('./prod.env'), index: path.resolve(__dirname, '../dist/index.html'), assetsRoot: path.resolve(__dirname, '../dist'), assetsSubDirectory: 'static', assetsPublicPath: './', productionSourceMap: false, productionGzip: false, productionGzipExtensions: ['js', 'css'] bundleAnalyzerReport: process.env.npm_config_report},
二、修改端口号8080为8888,防止端口冲突
进入config>index.js把修改port:8888 防止和其他端口冲突
dev: { env: require('./dev.env'), port: 8888,三、配置proxyTable 解决开发环境中的跨域问题
proxyTable: { '/aaa':{ target:'http://www.api.com/aaa', changeOrigin:true, pathRewrite:{ '^/aaa':'' } }},
然后接口是这样子写的
this.$http.get('/aaa/menu/get_list').then(function(data){ console.log(data)})
四、打包要去掉mode:’history‘,否则打包不成功
export default new Router({ // mode: 'history',//打包项目要把mode: history注释掉 routes: [ { path: '/', redirect:{name:'Into'} } ]})
五、有些图片引用失败 在build\webpack.prod.conf.js 的限制limit注释掉
{ test: /\.(png|jpe?g|gif|svg)(\?.*)?$/, loader: 'url-loader', options: { // limit: 10000, name: utils.assetsPath('img/[name].[hash:7].[ext]') }},
六、去掉打包后不要的.map文件 在config\index.js 中把productionSourceMap:true改成
productionSourceMap:false
build: { env: require('./prod.env'), index: path.resolve(__dirname, '../dist/index.html'), assetsRoot: path.resolve(__dirname, '../dist'), assetsSubDirectory: 'static', assetsPublicPath: './', productionSourceMap: false, productionGzip: false, productionGzipExtensions: ['js', 'css'] bundleAnalyzerReport: process.env.npm_config_report},
阅读全文
1 0
- (vue2.0 案例3.0) 在vue-cli 项目中 需要知道常见的配置 防止入坑
- 使用vue-cli 创建vue2.x项目中使用vue-router 与之前的区别
- Vue2.0 框架配置:vue-cli + vue-router + vuex
- Vue2.0 框架配置:vue-cli + vue-router + vuex
- vue2.0 使用vue-cli搭建的项目如何在index.html里引入静态css和js
- vue2.0项目笔记系列(1)——搭建Vue脚手架(vue-cli)
- 【vue2.0】解决使用vue-cli生成项目后项目地址自动添加#号的问题
- Vue2.0+Vue-cli脚手架
- vue2.0项目快速搭建工具——vue-cli
- Vue2.0 --- vue-cli脚手架中全局引入JQ
- vue2.0新手填坑攻略之使用vue-cli搭建vue项目开发环境到项目发布
- vue2.9.1-vue-cli几个配置
- 在Vue-cli项目中使用echarts
- (vue:案例02) vue-cli 如何搭建项目
- 基于webpack+Vue2.0搭建webapp(vue-cli原理)
- 使用vue cli开发项目中遇到的坑
- vue2.0基于vue-cli,element-ui饿了么vue前端开源项目制作vue的树形table,treeTable
- 用vue构建项目笔记5(在vue-cli项目中引用公用方法)(vue resource统一处理)
- Jdk8 HashMap源码阅读
- 服务器三大体系 SMP、NUMA、MPP 之详解
- ceres---cannot convert ‘const ceres::Jet<double, 6>’ to ‘double’
- 挑战程序竞赛系列(89):3.6平面扫描(3)
- mongo学习笔记(二)-复制
- (vue2.0 案例3.0) 在vue-cli 项目中 需要知道常见的配置 防止入坑
- solr6.1 安装,开发demo
- Android录制或播放语音消息时关闭其他媒体播放
- java基础之—String类学习笔记
- git工作原理
- React(一)初识
- 工作笔记之工具常用知识
- ListActivity的使用
- ......................