Closed slbb closed 6 months ago
Sorry I can't get the problem, can you provide some code or snapshots?
After npm run build
:
dist/assets/index-<hash>.js
got generateddist/index.html
got generated<script src="./assets/index-<hash>.js"></script>
tag links to the assets/index-<hash>.js
file in dist/index.html
1 & 2 is done. But missing 3, which means there is no <script src="./assets/index-<hash>.js"></script>
tag links to the assets/index-<hash>.js
file.
git clone https://github.com/emosheeep/vite-plugin-virtual-mpa
cd vite-plugin-virtual-map/example
npm i
npm run build
vite-plugin-virtual-mpa@1.10.1 vite@5.1.3
By the way, it works well with vite@4.5.3. The issue seems related to vite's recent changes.
I try to run dev mode and everything runs well,it seems a build error only 🤔.
That's weird. I cloned vite-plugin-virtual-map/example
and kept all the code untouched but still have problem.
No error during building.
~/vite-plugin-virtual-mpa/example (master)
$ pnpm build
> vite-plugin-virtual-mpa-demo@0.0.0 build C:\Users\asdf\vite-plugin-virtual-mpa\example
> vite build
[vite-plugin-virtual-mpa]: Generated virtual files:
<dist>/fruits/apple.html
<dist>/fruits/banana.html
<dist>/fruits/strawberries.html
<dist>/fruits/home.html
<dist>/fruits/home2.html
vite v5.1.3 building for production...
✓ 22 modules transformed.
dist/fruits/home.html 0.64 kB │ gzip: 0.42 kB
dist/fruits/apple.html 0.64 kB │ gzip: 0.41 kB
dist/fruits/home2.html 0.64 kB │ gzip: 0.42 kB
dist/fruits/banana.html 0.64 kB │ gzip: 0.42 kB
dist/fruits/strawberries.html 0.65 kB │ gzip: 0.42 kB
dist/assets/home2--MuPufAh.js 0.25 kB │ gzip: 0.22 kB │ map: 0.43 kB
dist/assets/apple-Oo8wSu7i.js 0.51 kB │ gzip: 0.32 kB │ map: 1.10 kB
dist/assets/strawberries-SjnQT__-.js 0.51 kB │ gzip: 0.32 kB │ map: 1.11 kB
dist/assets/banana-TXwiX3Uo.js 0.51 kB │ gzip: 0.33 kB │ map: 1.10 kB
dist/assets/home-gZvW4Z2x.js 0.51 kB │ gzip: 0.33 kB │ map: 1.09 kB
dist/assets/_plugin-vue_export-helper-bHOMJ4Sa.js 52.43 kB │ gzip: 21.18 kB │ map: 475.27 kB
✓ built in 1.19s
But no <script>
tags can be found.
~/vite-plugin-virtual-mpa/example (master)
$ cd dist
~/vite-plugin-virtual-mpa/example/dist (master)
$ rg '<script' -t html
~/vite-plugin-virtual-mpa/example/dist (master)
$ rg 'src' -t html
rg
is just for example here. I also have already checked them manually in the editor.
Maybe I should try on another computer.
Looks like I can only downgrade to vite 4.x to avoid this problem for now.
Nevertheless, thank you.
This is the script tag in demo project
<script type="module" crossorigin src="/assets/apple-Oo8wSu7i.js"></script>
Seems like it's a Windows specific problem. I create a test repo and build using github workflow. When it runs on ubuntu it works fine. Combined with that fact that vite4 works fine too, so maybe vite5 use some new feature of nodejs which nodejs cannot handle well under Windows.
For now,have you tried to start with slash?
For now,have you tried to start with slash?
Sorry, I don't get it. Where should I use slash?
BTW, I tried to debug the build process and found that code here does return the right html string with <script>
tag, but the final output is still missing that tag. So weird🤔
To find out the cause need a deeper dive into the code of vite 5 or even rollupjs.
Sorry I found you used scanOptions, it should be handled internally by the plugin. Maybe you can reference this issue in vite repo to find some help🙏.
Thank you very much.
After building, all the
.html
files generated by the plugin are missing the<script>
tag for entry script. It happens after updating vite-plugin-virtual-mpa (1.10.1) and vite (5.1.3). I'm not sure which is the cause. I've tried it in the example project of this repo and it reproduces the bug as well.