HorusGoul / vite-plugin-stylex

Vite Plugin for StyleX
MIT License
110 stars 11 forks source link

Inconsistent bundling of css assets between builds. Duplicated <link /> imports (`0.9.0-next.1`) #66

Open predaytor opened 3 months ago

predaytor commented 3 months ago

Sorry to bother you, but strangely there are some inconsistent issues with bundling assets on 0.9.0-next.1. I can't reproduce this in the sandbox, but I'll try to explore more.

The main issue is due to a duplicated style at the top of the document (Remix app), it seems to be related to the ?url import.

Duplicated CSS link at the top of the <head>
> remix vite:build

Using vars defined in .dev.vars
Using vars defined in .dev.vars
Using vars defined in .dev.vars
Using vars defined in .dev.vars
vite v5.2.8 building for production...
✓ 730 modules transformed.
build/client/.vite/manifest.json                1.72 kB │ gzip:  0.41 kB
build/client/.vite/ssr-manifest.json           11.99 kB │ gzip:  1.28 kB
build/client/assets/index-CBTc5Tqx.css         28.15 kB │ gzip:  8.60 kB
build/client/assets/signup-B3B1wjVr.js          0.04 kB │ gzip:  0.06 kB
build/client/assets/recovery-B_aj7I_9.js        0.04 kB │ gzip:  0.06 kB
build/client/assets/x-wIIi5Spc.js               0.69 kB │ gzip:  0.39 kB
build/client/assets/stylex-Ch64yUrd.js          1.45 kB │ gzip:  0.81 kB
build/client/assets/root-CzOl5Zlg.js            2.61 kB │ gzip:  1.30 kB
build/client/assets/entry.client-HhAWpzjk.js   14.02 kB │ gzip:  4.99 kB
build/client/assets/route-Csjim9h7.js          82.30 kB │ gzip: 22.22 kB
build/client/assets/components-B-X7-3JQ.js    269.88 kB │ gzip: 85.01 kB
✓ built in 1.64s
Using vars defined in .dev.vars
Using vars defined in .dev.vars
vite v5.2.8 building SSR bundle for production...
✓ 35 modules transformed.
build/server/.vite/manifest.json         0.34 kB
build/server/.vite/ssr-manifest.json     0.87 kB
build/server/assets/index-veiAjTuj.css  28.15 kB
build/server/index.js                   57.77 kB

✓ 1 asset moved from Remix server build to client assets.
build/client/assets/index-veiAjTuj.css

But sometimes (even during a re-build) all is fine, the hash of the css file from the SSR bundle is the same as the previous build step, and this line doesn't show up in the logs (maybe it's due to internal build caching, not sure):

✓ 1 asset moved from Remix server build to client assets.
build/client/assets/index-veiAjTuj.css
> remix vite:build

Using vars defined in .dev.vars
Using vars defined in .dev.vars
Using vars defined in .dev.vars
Using vars defined in .dev.vars
vite v5.2.8 building for production...
✓ 730 modules transformed.
build/client/.vite/manifest.json                1.72 kB │ gzip:  0.41 kB
build/client/.vite/ssr-manifest.json           11.99 kB │ gzip:  1.28 kB
build/client/assets/index-DdooBTxy.css         31.74 kB │ gzip:  8.67 kB
build/client/assets/signup-B3B1wjVr.js          0.04 kB │ gzip:  0.06 kB
build/client/assets/recovery-B_aj7I_9.js        0.04 kB │ gzip:  0.06 kB
build/client/assets/x-wIIi5Spc.js               0.69 kB │ gzip:  0.39 kB
build/client/assets/stylex-Ch64yUrd.js          1.45 kB │ gzip:  0.81 kB
build/client/assets/root-CC5FudlM.js            2.61 kB │ gzip:  1.30 kB
build/client/assets/entry.client-HhAWpzjk.js   14.02 kB │ gzip:  4.99 kB
build/client/assets/route-Csjim9h7.js          82.30 kB │ gzip: 22.22 kB
build/client/assets/components-B-X7-3JQ.js    269.88 kB │ gzip: 85.01 kB
✓ built in 1.50s
Using vars defined in .dev.vars
Using vars defined in .dev.vars
vite v5.2.8 building SSR bundle for production...
✓ 35 modules transformed.
build/server/.vite/manifest.json         0.34 kB
build/server/.vite/ssr-manifest.json     0.87 kB
build/server/assets/index-DdooBTxy.css  31.74 kB
build/server/index.js                   57.77 kB
✓ built in 272ms

Also, sometimes (I think due to the use of css layer() imports), this log occurs:

Error running vite:css on Tailwind CSS output. Skipping.

Sorry for such a vague description of the issue, I will definitely try to create a reproduction sandbox. (p.s. in production I use the @remix-run/cloudflare package instead of node).