Skip to content

Conversation

@neznaika0
Copy link
Contributor

I hope I understood the system for Vite correctly.
After all the manipulations, we will get the code (production) at the output:
build

✓ 115 modules transformed.
public/assets/.vite/manifest.json       0.82 kB │ gzip:   0.27 kB
public/assets/app-DrGlaGvg.css          0.90 kB │ gzip:   0.41 kB
public/assets/admin-BiirkHbY.css      121.97 kB │ gzip:  17.33 kB
public/assets/app-DolHVGNC.css        157.70 kB │ gzip:  24.45 kB
public/assets/admin-1Nd9UR-5.js         1.86 kB │ gzip:   0.91 kB
public/assets/module.esm-Dm5CBBXC.js  116.30 kB │ gzip:  35.07 kB
public/assets/app-Cs24vf4u.js         591.47 kB │ gzip: 186.24 kB
<script type="module" src="http://localhost:8080/assets/module.esm-Dm5CBBXC.js"></script>
<link rel="stylesheet" href="http://localhost:8080/assets/app-DrGlaGvg.css">
<script type="module" src="http://localhost:8080/assets/app-Cs24vf4u.js"></script>
<link rel="stylesheet" href="http://localhost:8080/assets/app-DolHVGNC.css">

<script type="module" src="http://localhost:8080/assets/module.esm-Dm5CBBXC.js"></script>
<script type="module" src="http://localhost:8080/assets/admin-1Nd9UR-5.js"></script>
<link rel="stylesheet" href="http://localhost:8080/assets/admin-BiirkHbY.css">

dev

<script type="module" src="http://localhost:5173/@vite/client"></script>
<script type="module" src="http://localhost:5173/themes/admin/js/admin.js"></script>
<link rel="stylesheet" href="http://localhost:5173/themes/admin/css/admin.scss">
  • Added the basic manifest.json parser. When new options become available, you will need to update the library. Now he understands styles, scripts, and dependencies. I may be wrong, check the tests.
  • Added tests. Tested the work in dev/prod modes. 100% coverage.
  • There is a TODO. I do not know an example right now. Skipped

@neznaika0
Copy link
Contributor Author

@lonnieezell @michalsn ready for review. Some similar tests can be shortened if you wish. Let us know that you have looked into PR, via emoj 👀
If you have repository notifications enabled, I'll wait next time.

@lonnieezell
Copy link
Owner

I'll have to pull this one down to give it a try. I'm not an expert on Vite either and was running into issues a couple of nights ago trying to pull stuff in as modules like that.

The vite() helper, though, does need updating. I remember creating it so that it worked for dev uses only and was going to need updating to insert the proper link for production code. Looks like you might have fleshed that out based on the description but I don't have a chance to look at the code in depth currently.

@neznaika0
Copy link
Contributor Author

neznaika0 commented Dec 4, 2025

You're right. I added the functions for the correct links in production (without the npm server). This does not affect Vite JS itself.

Our main goal is to have correct HTML embed code after build. It's done.
It only remains to supplement the code when the dependencies of the JS components appear.

For example, when the file app.js is huge, it can be split into pieces (app_part1.js, app_part_2.js). And each part needs to be inserted. It 's possible is the module.esm already doing this...?
If the app.js contains CSS imports, it already has a <link> for its file. It done.

To see the result, run npm run build and see how the forum and admin work. Check <head> tag.

The library is useful. This eliminates the need to manually insert scripts. They are always dynamic after the build.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants