#Astro build outputs dozens of js files for all frameworks
19 messages · Page 1 of 1 (latest)
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?
Houston, we have a problem... and <@&1129102257422610512>, you’re our mission control! 🚀
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.
You can try things like this:
vite: {
build: {
cssCodeSplit: false,
cssMinify: false,
minify: false
}
}
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.
And the cssCodeSplit: false doesn't help?
What are you using to write your CSS?
tailwind
cssCodeSplit appears to do what I need
is there a way to detect dev vs build in the astro config?
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.
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
That is all being included do to your usage of Shiki (code blocks highlighting)