vue-cli3之webpack配置

在项目的根目录,新建一个vue.config.js文件

// vue.config.js
const path = require("path");

const Timestamp = new Date().getTime();

module.exports = {
    configureWebpack: {
        resolve: {
            alias: {
                "@": path.resolve(__dirname, "./src"),
            },
        },
        output: { // 输出重构 打包编译后的 文件名称 【模块名称.版本号.时间戳】
            filename: `[name].${Timestamp}.js`,
            chunkFilename: `[name].${Timestamp}.js`
        },
    },
    css: {
        loaderOptions: {
            sass: {
                // 根据自己样式文件的位置调整
                prependData: `@import "@/assets/css/variables.scss";`, //这里的@是别名
            },
        },
    },

    lintOnSave: false,
    devServer: {
        overlay: { // 让浏览器 overlay 同时显示警告和错误
            warnings: true,
            errors: true
        },
        host: "",
        port: 8080, // 端口号
        https: false, // https:{type:Boolean}
        open: true, //配置后自动启动浏览器
        hotOnly: true, // 热更新
        // proxy: 'http://localhost:8080'   // 配置跨域处理,只有一个代理
        proxy: { //配置多个跨域
            "/": {
                // target: "http://10.18.200.47:8080", // 本地
                // target: "http://10.220.184.106:8080", // 生产
                target: "http://10.220.184.110:8080", // 开发
                changeOrigin: true,
                ws: true, //websocket支持
                secure: false,
                pathRewrite: {
                    "^/": ""
                },
                headers: {
                    // Referer: "http://10.18.200.47:8080", // 本地
                },
            },
        }
    },
}

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值