Skip to content

Commit 081b240

Browse files
esbuild respects vite.build.minify option (#6222)
* esbuild respects `vite.build.minify` option * Docs update --------- Co-authored-by: AirBorne04 <> Co-authored-by: Yan Thomas <[email protected]>
1 parent ec5f6a0 commit 081b240

File tree

3 files changed

+25
-2
lines changed

3 files changed

+25
-2
lines changed

.changeset/many-eels-wait.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@astrojs/cloudflare': patch
3+
---
4+
5+
add option to compile unminified code

packages/integrations/cloudflare/README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,10 +108,28 @@ By default, `@astrojs/cloudflare` will generate a `_routes.json` file that lists
108108

109109
## Troubleshooting
110110

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

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

116+
### Meaningful error messages
117+
118+
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`
119+
120+
```
121+
export default defineConfig({
122+
adapter: cloudflare(),
123+
output: 'server',
124+
125+
vite: {
126+
build: {
127+
minify: false
128+
}
129+
}
130+
});
131+
```
132+
115133
## Contributing
116134

117135
This package is maintained by Astro's Core team. You're welcome to submit an issue or PR!

packages/integrations/cloudflare/src/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,15 +95,15 @@ export default function createIntegration(args?: Options): AstroIntegration {
9595
// A URL for the final build path after renaming
9696
const finalBuildUrl = pathToFileURL(buildPath.replace(/\.mjs$/, '.js'));
9797

98-
await esbuild.build({
98+
await esbuild.build({
9999
target: 'es2020',
100100
platform: 'browser',
101101
entryPoints: [entryPath],
102102
outfile: buildPath,
103103
allowOverwrite: true,
104104
format: 'esm',
105105
bundle: true,
106-
minify: true,
106+
minify: _config.vite?.build?.minify !== false,
107107
banner: {
108108
js: SHIM,
109109
},

0 commit comments

Comments
 (0)