Skip to content

Commit

Permalink
fix: push-manifest.json CSS asset type (#1736)
Browse files Browse the repository at this point in the history
* fix: CSS in push-manifest was labeled as a script

* docs: Adding changeset

* refactor: Skips over already set file attrs when generating push-manifest
  • Loading branch information
rschristian committed Nov 18, 2022
1 parent 691a4e2 commit 396aec8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
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

0 comments on commit 396aec8

Please sign in to comment.