【vue】vue.config.js

const goods = require('./data/goods.json');
const ratings = require('./data/ratings.json');
const seller = require('./data/seller.json');

module.exports = {
publicPath: './', //输出的根路径 默认是/ 如果你的网站是app.com/vue 这更改此配置项
outputDir: 'dist',//构建输出目录
assetsDir: 'assets',//静态资源目录(js,css,img,fonts)
lintOnSave: false,//是否开启eslint保存检测,有效值:ture||false||'error'

devServer: {
open: true, //开启浏览器
host: 'localhost',
port: 8081,
https: false,
hotOnly: false,
proxy: {//配置跨域
'/api': {
target: "http//localhost:5000/api/",
ws: true,//是否跨域
changOrigin: true,//配置跨域
pathRewrite: {//重定向
'^/api': ''
}
}
},
before(app) {// http://localhost:8081/api/goods
app.get('/api/goods',(req,res) => {
res.json(goods);
})
app.get('/api/ratings',(req,res) => {
res.json(ratings);
})
app.get('/api/seller',(req,res) => {
res.json(seller);
})
}
}
}
posted @ 2019-04-03 12:27  雨雪粪痘凯文  阅读(376)  评论(0编辑  收藏  举报