// vue.config.js 配置说明
"use strict"; //严格模式
const path = require("path");
console.log(path); //获取了路径
function resolve(dir) {
return path.join(__dirname, dir);
}
module.exports = {
/*
publicPath
Type: string
Default: '/'
部署应用包时的基本 URL, 用法和 webpack 本身的 output.publicPath 一致
这个值也可以被设置为空字符串 ('') 或是相对路径 ('./'),
这样所有的资源都会被链接为相对路径,这样打出来的包可以被部署在任意路径
*/
publicPath: "/", // 基本路径
/*
outputDir
Type: string
Default: 'dist'
输出文件目录,当运行 vue-cli-service build 时生成的生产环境构建文件的目录。
注意目标目录在构建之前会被清除 (构建时传入 --no-clean 可关闭该行为)。
*/
outputDir: "dist", // 输出文件目录
/*
assetsDir
Type: string
Default: ''
放置生成的静态资源 (js、css、img、fonts) 的目录。
*/
assetsDir: "static",
lintOnSave: false, //是否开启eslint保存检测
/*
devServer
Type: Object
devServer.proxy
Type: string | Object
如果你的前端应用和后端api服务器没有运行在一个主机上
你需要在开发环境下将api请求代理到api服务器
*/
devServer: {
//webpack-dev-server 相关配置
proxy: {
//允许所有的主机访问当前项目
host: '0.0.0.0',//允许所有的主机都能访问 监听0.0.0.0的端口,就是监听本机中所有IP的端口
'/api': 'http://localhost:3000',
//代理
// 请求到 /api/xxx 现在会被代理到请求 http://localhost:3000/api/xxx,
// 就是往/api/xxx 前面添加协议域名和端口 http://localhost:3000;
// 还可以代理多个路径
//忽略api前缀
'/api': {
target: 'http://localhost:3000',
pathRewrite: {'^/api' : ''},//对于请求路径进行重定向以匹配到正确的地址
changeOrigin:true,//本地就会虚拟一个服务器接收你的请求并代你发送该请求
// 本地虚拟一个服务器用于发送你的请求 服务器和服务器之间没有跨域问题
},
//请求到/api/xxx 现在会被代理到 http://localhost:3000/xxx
}
},
};
/* 需要学习 node 这个东西 */
/* 端口号 设置端口号 port
同源策略 同协议 同域名 同端口
在nginx配置的时候 就可以 替换接口
类似于
下面是nginx.conf 文件中的一些配置文件 类似于这种
server {
listen 9012;
server_name 27.150.26.146;
location / {
root html/guangxi;
index index.html;
}
location /v-demand/ {
proxy_pass http://localhost:8082/;
}
location /v-analysis/ {
proxy_pass http://localhost:8091/;
}
location /v-asserts/ {
proxy_pass http://localhost:8082/;
}
location /v-web/ {
proxy_pass http://localhost:8089/;
}
location /v-customer/ {
proxy_pass http://localhost:8092/;
}
}
*/
/*
*/
// module.exports = {
// lintOnSave: false,
// // 这里瞎配置的
// devServer: {
// proxy: {
// "/api": {
// // target: "http://179.10.0.94:9016",
// target: "http://179.10.0.94:9050",
// pathRewrite: {
// "^/api": "",
// },
// ws: true,
// changeOrigin: true,
// },
// },
// port: 9051,//用于设置端口号
// },
// publicPath: "./",
// };
vue.config.js 配置文件 的使用 记录一下
最新推荐文章于 2024-06-15 22:33:31 发布