当前位置: 首页 > news >正文

vue3 - Vue 项目处理GitHub Pages 部署后 _plugin-vue_export-helper.js 404

GitHub Demo 地址

在线预览

vue3项目打包后部署到github pages 后,预览网站提示下划线开头的一个文件_plugin-vue_export-helper访问不到,网络请求显示404

处理GitHub Pages 部署 _plugin-vue_export-helper.js 404
https://github.com/rollup/rollup/blob/master/src/utils/sanitizeFileName.ts

解决办法

需要修改配置 vite.config.js,重写打包的方案

// 打包配置const INVALID_CHAR_REGEX = /[\u0000-\u001F"#$&*+,:;<=>?[\]^`{|}\u007F]/g
const DRIVE_LETTER_REGEX = /^[a-z]:/iexport function setupBuild() {return {outDir: 'dist',sourcemap: false,// 消除打包大小超过500kb警告chunkSizeWarningLimit: 2000,rollupOptions: {input: {index: 'index.html'},// 静态资源分类打包output: {chunkFileNames: 'static/js/[name]-[hash].js',entryFileNames: 'static/js/[name]-[hash].js',assetFileNames: 'static/[ext]/[name]-[hash].[ext]',// TODO: 处理GitHub Pages 部署 _plugin-vue_export-helper.js 404// https://github.com/rollup/rollup/blob/master/src/utils/sanitizeFileName.tssanitizeFileName(name: any) {const match = DRIVE_LETTER_REGEX.exec(name)const driveLetter = match ? match[0] : ''// A `:` is only allowed as part of a windows drive letter (ex: C:\foo)// Otherwise, avoid them because they can refer to NTFS alternate data streams.return driveLetter + name.slice(driveLetter.length).replace(INVALID_CHAR_REGEX, '')},manualChunks(id: any) {if (id.includes('node_modules')) {return id.toString().match(/\/node_modules\/(?!.pnpm)(?<moduleName>[^\/]*)\//)?.groups!.moduleName ?? 'vender'}}// manualChunks(id) {//   if (id.includes('node_modules')) {//     return id.toString().split('node_modules/')[1].split('/')[0].toString()//   }// }}}}
}

vite.config.ts文件引入

import { setupBuild } from './build/index'export default defineConfig({build: setupBuild(),
});
http://www.lryc.cn/news/172294.html

相关文章:

  • 一百八十一、Hive——海豚调度HiveSQL任务时当Hive的计算引擎是mr或spark时脚本的区别(踩坑,附截图)
  • Linux 隔离网段下端口转发
  • 【CDN和UDN】CDN和UDN技术特点以及使用场景
  • 【Linux】改变缓存路径、清理缓存
  • python+opencv寻找图片或视频中颜色进行追踪之HSV颜色处理
  • ubuntu 22.04 服务器网卡无IP地址
  • 基于SpringBoot的网上点餐系统
  • 浅谈xss
  • 悬崖边:企业如何应对网络安全漏洞趋势
  • MyBatis 动态 SQL、MyBatis 标签、MyBatis关联查询
  • 在Vue中使用Immutable.js
  • 基于Yolov8的工业端面小目标计数检测(1)
  • 1.什么是jwt?jwt的作用是什么?2.jwt的三个部分是什么?三者之间的关系如何?3.JWT运行的流程是什么
  • 十三、MySql的视图
  • MFC扩展库BCGControlBar Pro v33.6亮点 - 流程图、Ribbon Bar功能升级
  • 前端 JS 经典:文件流下载
  • SSL免费证书会报安全提示吗?
  • 为什么要选择Spring cloud Sentinel
  • 第八天:gec6818arm开发板和Ubuntu中安装并且编译移植mysql驱动连接QT执行程序
  • 使用JavaScript实现图片的自动轮播
  • React 如何拿时间戳计算得到开始和结束时间戳
  • leetcode114 二叉树展开为链表
  • Linux系统上使用SQLite
  • 实现一个超级简单的string类(基于c++)
  • uniapp存值和取值,获取登录凭证 code方法
  • 【SpringCloud微服务全家桶学习笔记-服务调用Ribbon/openFeign】
  • Qt使用I.MX6U开发板上的按键(原理:将电脑键盘方向键↓在Qt中的枚举值与开发板中按键定义的枚举值一致,这样电脑端测试效果就与开发板的一致)
  • C++ RAII在HotSpot VM中的重要应用
  • python随手小练
  • MySQL——函数和流程控制