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

fix: push-manifest.json CSS asset type #1736

Merged
merged 5 commits into from Nov 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/shy-poets-sneeze.md
@@ -0,0 +1,5 @@
---
'preact-cli': patch
---

Fix for CSS assets sometimes being mistakenly labeled as 'scripts' in the push-manifest.
3 changes: 2 additions & 1 deletion packages/cli/lib/lib/webpack/create-load-manifest.js
Expand Up @@ -41,7 +41,7 @@ module.exports = (assets, namedChunkGroups, isProd) => {
const routeJs = assets[`${route}.js`];

routeManifest[routeJs] = { type: 'script', weight: 0.9 };
if (routeCss) routeManifest[routeCss] = { type: 'script', weight: 0.9 };
if (routeCss) routeManifest[routeCss] = { type: 'style', weight: 0.9 };

const path = route.replace(/^route-/, '/').replace(/^\/home/, '/');

Expand All @@ -52,6 +52,7 @@ module.exports = (assets, namedChunkGroups, isProd) => {
asyncFiles.chunks.forEach(asset => {
asset.files = asset.files || [];
asset.files.forEach(file => {
if (routeManifest[file]) return;
if (/\.css$/.test(file)) {
routeManifest[file] = { type: 'style', weight: 0.9 };
} else if (/\.js$/.test(file)) {
Expand Down