Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Windows上当base'''./'时,打包后HTML里的资源路径会包含项目所在的目录 #43

Closed
Xli33 opened this issue May 15, 2023 · 6 comments · Fixed by #46
Assignees

Comments

@Xli33
Copy link

Xli33 commented May 15, 2023

可以在Windows上使用这个demo复现,只用了vite和插件

因为不能限制base为固定的名字,所以想着用 '' / ./ 了,开发时没问题,然鹅打包后(⊙o⊙)…

没用插件时的配置

export default {
  base: '', // './'也一样
};

打包后资源的路径是以 ./ 开头的,这时是对的

image

但是使用了插件后,生成的路径就会包含项目所在的目录路径

export default {
  base: '',
  plugins: [
    createMpaPlugin({
      pages: [
        {
          name: 'index'
        }
      ]
    }),
  ],
};

image

也下载了仓库里的example试过,但只要把base改成 '' 或 './' 后结果都是一样了,甚至文件夹名字太长还会被截断 (ಥ﹏ಥ)

@emosheeep
Copy link
Owner

可以看看你的配置吗

@Xli33
Copy link
Author

Xli33 commented May 16, 2023

可以看看你的配置吗

不好意思,忘了说上面的截图就是在本机上用那个demo弄的,配置是这样的

import { createMpaPlugin } from 'vite-plugin-virtual-mpa';

export default {
  base: '',
  plugins: [
    createMpaPlugin({
      pages: [
        {
          name: 'index'
        }
      ]
    }),
  ],
};

@emosheeep
Copy link
Owner

我有空借个windows电脑看下,现在在上班没法看,你如果着急或者有空,可以提个PR,等我的话,我是不能保证什么时候有时间的

@Xli33
Copy link
Author

Xli33 commented May 16, 2023

我有空借个windows电脑看下,现在在上班没法看,你如果着急或者有空,可以提个PR,等我的话,我是不能保证什么时候有时间的

么事,这个不急,后面先用其他方式曲线救国了
P.S 抱歉打扰工作、、(。・_・。)ノ

@emosheeep
Copy link
Owner

emosheeep commented Jun 2, 2023

我今天借到了一台 windows 看了下这个,我感觉可能是 vite 的问题,我在 windows 系统中复现了一个最小 demo,但同样的 demo 在 MacOS 上一切正常,所以我去提了一个 vitejs/vite#13406 ,等等后续再看。

@Xli33
Copy link
Author

Xli33 commented Jun 2, 2023

我今天借到了一台 windows 看了下这个,我感觉可能是 vite 的问题,我在 windows 系统中复现了一个最小 demo,但同样的 demo 在 MacOS 上一切正常,所以我去提了一个 vitejs/vite#13406 ,等等后续再看。

好哒,大佬辛苦了(・ω・)ノ

@emosheeep emosheeep self-assigned this Jun 4, 2023
emosheeep added a commit that referenced this issue Jun 4, 2023
@emosheeep emosheeep pinned this issue Jun 4, 2023
emosheeep added a commit that referenced this issue Jun 4, 2023
emosheeep added a commit that referenced this issue Jun 4, 2023
@emosheeep emosheeep unpinned this issue Feb 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants