vue2 打包文件配置

  在项目的根目录中创建webpack.config.js文件

    配置webpack.config.js文件,如下代码

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
const { defineConfig } = require("@vue/cli-service");
module.exports = defineConfig({
    // 项目部署的基本路径,默认 "/"
    publicPath: './',
 
    // 项目打包的根目录,默认 "dist"
    outputDir: "dist",
 
    // 项目打包的静态资源存放目录,默认 ""
    assetsDir: "static",
 
    // 项目打包的index.html输出路径,默认 "index.html"
    indexPath: "index.html",
 
    // 多页应用配置参数,默认 undefined
    pages: undefined,
 
    // 开发环境 eslint 异常信息提示位置,默认 "default" 在浏览器窗口提示,为 true 在控制台提示
    lintOnSave: process.env.NODE_ENV === 'development',
 
    // 项目打包是否生成js的 source map 调试包,默认 true,生产部署设置为false
    productionSourceMap: false,<br>
    //跨域配置
    devServer: {
        proxy: {
          '/api': {    // 被代理的接口名
            target:'',    //要跨域的域名
            changeOrigin: true,   //是否开启跨域
            pathRewrite: {
              '^/api': '',
            },
          }
        }
      },<br>
    transpileDependencies: true,
});

  

注:该文档为个人理解所写,有误可建议修改

 

本文作者:persistIn

本文链接:https://www.cnblogs.com/persistIn/p/17769070.html

版权声明:本作品采用知识共享署名-非商业性使用-禁止演绎 2.5 中国大陆许可协议进行许可。

posted @   persist_in  阅读(786)  评论(0编辑  收藏  举报
点击右上角即可分享
微信分享提示
💬
评论
📌
收藏
💗
关注
👍
推荐
🚀
回顶
收起
🔑