Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/altipla-consulting/astro-unminify-cloudflare
Astro integration to unminify the generated Cloudflare worker.
https://github.com/altipla-consulting/astro-unminify-cloudflare
astro cloudflare-pages
Last synced: about 2 months ago
JSON representation
Astro integration to unminify the generated Cloudflare worker.
- Host: GitHub
- URL: https://github.com/altipla-consulting/astro-unminify-cloudflare
- Owner: altipla-consulting
- License: mit
- Created: 2024-01-10T22:17:43.000Z (12 months ago)
- Default Branch: main
- Last Pushed: 2024-01-10T22:39:26.000Z (12 months ago)
- Last Synced: 2024-11-09T02:18:22.013Z (2 months ago)
- Topics: astro, cloudflare-pages
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/astro-unminify-cloudflare
- Size: 23.4 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# astro-unminify-cloudflare
Astro integration to unminify the generated Cloudflare worker.
The Astro Cloudflare integration minifies the generated `worker.js` file by default depending on the global vite configuration. This causes some issues:
- Deployments sometimes fail with no apparent reason.
- Any stack traces from errors become useless if the code is compiled.
- Globally disabling minification also affects client scripts, significantly increasing their size and preventing the usual framework optimizations.This integration disables minification only for the server-side, preserving all critical optimizations for the client. This approach maintains the benefits of having a plain file that can be easily deployed to Cloudflare Pages, while avoiding the aforementioned issues.
## Install
```shell
npm astro add astro-unminify-cloudflare
```## Example Astro config
Remember that you need to enable the Cloudflare adapter and build with `server` or `hybrid` mode to have a SSR worker to unminify. This is an example configuration file for reference only:
```ts
import { defineConfig } from 'astro/config'
import vue from '@astrojs/vue'
import tailwind from '@astrojs/tailwind'
import unminifyCloudflare from 'astro-unminify-cloudflare'
import cloudflare from '@astrojs/cloudflare'export default defineConfig({
output: 'server',
adapter: cloudflare({
imageService: 'passthrough',
}),
trailingSlash: 'never',
build: {
format: 'file',
},
integrations: [
vue(),
tailwind(),
unminifyCloudflare(),
],
})
```