#Astro build outputs dozens of js files for all frameworks

19 messages · Page 1 of 1 (latest)

lime marlin
#

Astro v5.7.13
Node v22.15.0
System macOS (arm64)
Package Manager npm
Output static
Adapter none
Integrations none

lime marlin
#

Looks like this is default behavior, as a dev on our team added a bunch of pages that caused this

#

We're using Astro as a frontend dev sandbox to build UI for a backend CMS team. So, we don't need a fully working Astro app. All I need output is a single bundled CSS file and items from the public folder, but the default in Astro automatically outputs all this stuff based on pages. This makese sense for it's standard use case, but I need to customize ours. Can anyone point me in the right direction for how to customize the build to only do what we need?

marble sparrowBOT
#

Houston, we have a problem... and <@&1129102257422610512>, you’re our mission control! 🚀

stuck atlas
#

Hi @lime marlin
This is code splitting that you see at work, here. Astro isn't handling per se, it's the bundler that does it.
Astro uses "Vite" as its bundle orchestrator, so this is where you should look.

#

The behaviour of vite can be changed inside your astro.config.ts, under the vite field.

lime marlin
#

Thanks

#

I've been playing with that and finding it hard to get what I want. I want Astro to function in it's default way when running npm run dev, for local development. But when I run npm run build, I want only one CSS file that is based on a single entry CSS file.

stuck atlas
#

And the cssCodeSplit: false doesn't help?
What are you using to write your CSS?

lime marlin
#

tailwind

#

cssCodeSplit appears to do what I need

#

is there a way to detect dev vs build in the astro config?

stuck atlas
# lime marlin tailwind

Interesting, I've always had a single CSS file produced by Tailwind. 🤔
It's supposed to be the whole point, it generates a single very small file that can be served on every page.

lime marlin
#

I want to be able to define conditional items in the astro config based on if it's local dev or build

#

@stuck atlas I'm not seeing examples of that in the config referrence. Am I missing it? is it possible?

#

or I could use env variables, I suppose

rapid pelican
#

That is all being included do to your usage of Shiki (code blocks highlighting)