Skip to content

Conversation

carylwyatt
Copy link
Member

@carylwyatt carylwyatt commented Apr 9, 2025

Vite is on version 6, but firebird has been on v4. This updates firebird to version 5, which is a step in the right direction!

Vite 5 changed how it outputs the build manifest, which had downstream effects on every HT front-end application.

manifest.json

The current prod manifest looks like this

{
  "assets/meow_jamming.gif": {
    "file": "assets/meow_jamming-5a9676cc.gif",
    "src": "assets/meow_jamming.gif"
  },
  "index.css": {
    "file": "assets/index-815bbd64.css",
    "src": "index.css"
  },
  "index.html": {
    "css": [
      "assets/index-815bbd64.css"
    ],
    "file": "assets/index-ab459272.js",
    "isEntry": true,
    "src": "index.html"
  }
}

and v5 was giving something like

{
  "index.html": {
    "file": "assets/index-CQTuhIzg.js",
    "name": "index",
    "src": "index.html",
    "isEntry": true,
    "css": [
      "assets/index-D63KU4Hj.css"
    ]
  }
}

Honestly, I like the new version and it makes more sense to me! But our applications are looking for specific file names, and it's easier to fix it in firebird than rename scripts in every other application.

Adding cssCodeSplit: false to the config breaks the css file into its own object:

{
  "index.html": {
    "file": "assets/index-Cqe2tiJw.js",
    "name": "index",
    "src": "index.html",
    "isEntry": true
  },
  "style.css": {
    "file": "assets/style-D63KU4Hj.css",
    "src": "style.css"
  }
}

But then I tinkered some more with the config file to replace style.css with index.css:

  • added an output option to the rollup section of the config that renames the build/compiled css file from style.css (v5) to index.css (to match v4)
  • added a custom plugin (postbuild-commands) that hooks into the closeBundle function and replaces a different style.css with index.css

Which spits out this manifest in the end:

{
  "index.html": {
    "file": "assets/index-Cqe2tiJw.js",
    "name": "index",
    "src": "index.html",
    "isEntry": true
  },
  "index.css": {
    "file": "assets/index-D63KU4Hj.css",
    "src": "style.css"
  }
}

The manifest was looking great, but the storybook build was upset about the vite config changes, so I filtered the plugins in the storybook config to not use that postbuild-commands plugin.

I tested this on dev-3 and it's working! I'm not sure there's anything to test here, just looking for a second set of eyes!

Edit to add: There was a testing error where vitest couldn't find happy-dom, so I upgraded vitest, vitest/coverage-istanbul, and added happy-dom as a dev dependency.

@carylwyatt carylwyatt requested a review from aelkiss April 10, 2025 13:46
Copy link
Member

@aelkiss aelkiss left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems reasonable for now, especially given that it's (hopefully) temporary until such time as we might be able to move to Svelte 5 & Vite 6. I would still probably suggest adding some comments here indicating why we're doing this and that it shouldn't be necessary later on.

@carylwyatt carylwyatt merged commit cfaadaf into main Apr 14, 2025
6 checks passed
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