Skip to content

Commit

Permalink
esbuild respects vite.build.minify option (#6222)
Browse files Browse the repository at this point in the history
* esbuild respects `vite.build.minify` option
* Docs update
---------
Co-authored-by: AirBorne04 <>
Co-authored-by: Yan Thomas <[email protected]>
  • Loading branch information
AirBorne04 authored Apr 27, 2023
1 parent ec5f6a0 commit 081b240
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/many-eels-wait.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@astrojs/cloudflare': patch
---

add option to compile unminified code
18 changes: 18 additions & 0 deletions packages/integrations/cloudflare/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,28 @@ By default, `@astrojs/cloudflare` will generate a `_routes.json` file that lists

## Troubleshooting


For help, check out the `#support` channel on [Discord](https://astro.build/chat). Our friendly Support Squad members are here to help!

You can also check our [Astro Integration Documentation][astro-integration] for more on integrations.

### Meaningful error messages

Currently, errors during running your application in Wrangler are not very useful, due to the minification of your code. For better debugging, you can add `vite.build.minify = false` setting to your `astro.config.js`

```
export default defineConfig({
adapter: cloudflare(),
output: 'server',
vite: {
build: {
minify: false
}
}
});
```

## Contributing

This package is maintained by Astro's Core team. You're welcome to submit an issue or PR!
Expand Down
4 changes: 2 additions & 2 deletions packages/integrations/cloudflare/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,15 +95,15 @@ export default function createIntegration(args?: Options): AstroIntegration {
// A URL for the final build path after renaming
const finalBuildUrl = pathToFileURL(buildPath.replace(/\.mjs$/, '.js'));

await esbuild.build({
await esbuild.build({
target: 'es2020',
platform: 'browser',
entryPoints: [entryPath],
outfile: buildPath,
allowOverwrite: true,
format: 'esm',
bundle: true,
minify: true,
minify: _config.vite?.build?.minify !== false,
banner: {
js: SHIM,
},
Expand Down

0 comments on commit 081b240

Please sign in to comment.