const path = require('path') const resolve = dir => { return path.join(__dirname, dir) } // 项目部署基础 // 默认情况下,我们假设你的应用将被部署在域的根目录下, // 例如:https://www.my-app.com/ // 默认:'/' // 如果您的应用程序部署在子路径中,则需要在这指定子路径 // 例如:https://www.foobar.com/my-app/ // 需要将它改为'/my-app/' // iview-admin线上演示打包路径: https://file.iviewui.com/admin-dist/ const BASE_URL = process.env.NODE_ENV === 'production' ? '/' : '/' module.exports = { // Project deployment base // By default we assume your app will be deployed at the root of a domain, // e.g. https://www.my-app.com/ // If your app is deployed at a sub-path, you will need to specify that // sub-path here. For example, if your app is deployed at // https://www.foobar.com/my-app/ // then change this to '/my-app/' // baseUrl: BASE_URL, // tweak internal webpack configuration. // see https://github.com/vuejs/vue-cli/blob/dev/docs/webpack.md // 如果你不需要使用eslint,把lintOnSave设为false即可 lintOnSave: false, chainWebpack: config => { config.resolve.alias // .set('~', resolve('src/assets')) .set('@', resolve('src')) // key,value自行定义,比如.set('@@', resolve('src/components')) .set('_c', resolve('src/components')) .set('_p', resolve('src/plugin')) // config.module // .rule(/\.js$/) // .use('babel-loader') // .loader('babel-loader') // .exclude(__dirname + 'node_modules') // .include(__dirname + 'src') // .tap(options => { // // 修改它的选项... // options={presets: ['env']} // return options // }) }, // 打包时不生成.map文件 productionSourceMap: false, // 这里写你调用接口的基础路径,来解决跨域,如果设置了代理,那你本地开发环境的axios的baseUrl要写为 '' ,即空字符串 devServer: { // proxy: 'http://127.0.0.1:10086', disableHostCheck: true, proxy:{ //设置代理,必须填 '/api':{ //设置拦截器 拦截器格式 斜杠+拦截器名字,名字可以自己定 target:'https://qyapi.weixin.qq.com', //代理的目标地址,这是豆瓣接口地址网址 changeOrigin:true, //是否设置同源,输入是的 pathRewrite:{ //路径重写 '/api':'' //路径转发代理 /api 的意思就是 用/api 代替http:localhost:8080 } }, '':{ target:'http://127.0.0.1:10086', } } } }