astro-generic-build-filenames v0.3.0
astro-generic-build-filenames
This is an Astro integration that modifies the filenames of build assets to more generic names.
This package is designed to eliminate confusion caused by the default naming convention, which names files after their entry points.
After astro build, asset files have a name based on the entry point, which result in main stylesheet names like 404.[hash].css or about-us.[hash].js. The same happens to assets and chunks.
Provided workarounds like directly setting vite.build.rollupOptions.output.entryFileNames do not work reliably with adapters like @astrojs/vercel or @astrojs/cloudflare.
This integration provides a wrapper around the originally used vite.build.rollupOptions.output.*FileNames keys and just replaces [name] with 'entry', 'chunk' or 'asset'.
Usage
Prerequisites
Your normal Astro project.
Installation
Install the integration automatically using the Astro CLI:
pnpm astro add astro-generic-build-filenamesnpx astro add astro-generic-build-filenamesyarn astro add astro-generic-build-filenamesOr install it manually:
- Install the required dependencies
pnpm add astro-generic-build-filenamesnpm install astro-generic-build-filenamesyarn add astro-generic-build-filenames- Add the integration to your astro config
+import genericBuildFilenames from "astro-generic-build-filenames";
export default defineConfig({
integrations: [
+ genericBuildFilenames(),
],
});Configuration
No configuration needed ... So far.
To-Do
- Add configuration for filenames
- Add tests (?)
Contributing
This package is structured as a monorepo:
playgroundcontains code for testing the packagepackagecontains the actual package
Install dependencies using pnpm:
pnpm i --frozen-lockfileStart the playground and package watcher:
pnpm devYou can now edit files in package. Please note that making changes to those files may require restarting the playground dev server.
Licensing
MIT Licensed. Made with ❤️ by Matthias Schöffmann.
Acknowledgements
Based on astro-integration-template