vue3打包注意事项

无敌的宇宙
无敌的宇宙
擅长邻域:Java,HTML,JavaScript,MySQL,支付,退款,图片上传

分类: vue 专栏: vue 标签: vue3打包注意事项

2025-11-26 21:27:20 108浏览

vue3打包注意事项
 import { createRouter, createWebHistory,createWebHashHistory } from 'vue-router'



const router = createRouter({
  // history: createWebHistory(process.env.BASE_URL),
  history: createWebHashHistory(),
  routes,

})

vue.config.js

const { defineConfig } = require('@vue/cli-service')
module.exports = defineConfig({
  transpileDependencies: true
})

//以上是自动生成的,下面是为解决跨域加的
module.exports = {
  lintOnSave: false,
  publicPath:'./',//打包需要
  // devServer: {
  //   host:'localhost',
  //   port:9999, //前端项目端口号 选填
  //   proxy: {                 //设置代理,必须填
  //     '/api': {
  //       target: 'http://localhost:8888', // 配置访问的服务器地址
  //       pathRewrite: { '^/api': '' },  // 用于将请求中的/api字符串替换为空, 然后访问地址就能正确访问,若不添加此行配置,那么访问地址就变成了: http://localhost:8080/api/request_url,这样的请求就会出现 404 操作
  //       ws: true, // 是否支持 websocket, 默认是 true
  //       changeOrigin: true // 用于控制请求头中的 host 值, 默认是 true
  //     }
  //   }
  // },
  configureWebpack: {//打包可能需要,根据报错文件过大提示决定是否加入
    performance: {
      hints: 'warning',
      maxEntrypointSize: 50000000,  // 入口点最大500KB
      maxAssetSize: 50000000        // 资源文件最大500KB
    }
  }
}

好博客就要一起分享哦!分享海报

此处可发布评论

评论(0展开评论

暂无评论,快来写一下吧

展开评论

您可能感兴趣的博客

客服QQ 1913284695