diff options
author | 2023-04-27 10:11:05 +0200 | |
---|---|---|
committer | 2023-04-27 10:11:05 +0200 | |
commit | 081b2402cfb48b5eb8dbd02664d8af2f7c798edf (patch) | |
tree | b79e97b0c3669bb3caea060c74bfa81b161f4d5e | |
parent | ec5f6a07ae68849e8117cfea2934081e3acc42a4 (diff) | |
download | astro-081b2402cfb48b5eb8dbd02664d8af2f7c798edf.tar.gz astro-081b2402cfb48b5eb8dbd02664d8af2f7c798edf.tar.zst astro-081b2402cfb48b5eb8dbd02664d8af2f7c798edf.zip |
esbuild respects `vite.build.minify` option (#6222)
* esbuild respects `vite.build.minify` option
* Docs update
---------
Co-authored-by: AirBorne04 <>
Co-authored-by: Yan Thomas <61414485+Yan-Thomas@users.noreply.github.com>
-rw-r--r-- | .changeset/many-eels-wait.md | 5 | ||||
-rw-r--r-- | packages/integrations/cloudflare/README.md | 18 | ||||
-rw-r--r-- | packages/integrations/cloudflare/src/index.ts | 4 |
3 files changed, 25 insertions, 2 deletions
diff --git a/.changeset/many-eels-wait.md b/.changeset/many-eels-wait.md new file mode 100644 index 000000000..8385894fc --- /dev/null +++ b/.changeset/many-eels-wait.md @@ -0,0 +1,5 @@ +--- +'@astrojs/cloudflare': patch +--- + +add option to compile unminified code diff --git a/packages/integrations/cloudflare/README.md b/packages/integrations/cloudflare/README.md index 207952185..2e61063db 100644 --- a/packages/integrations/cloudflare/README.md +++ b/packages/integrations/cloudflare/README.md @@ -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! diff --git a/packages/integrations/cloudflare/src/index.ts b/packages/integrations/cloudflare/src/index.ts index f5c4fc370..bbe8c65c7 100644 --- a/packages/integrations/cloudflare/src/index.ts +++ b/packages/integrations/cloudflare/src/index.ts @@ -95,7 +95,7 @@ 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], @@ -103,7 +103,7 @@ export default function createIntegration(args?: Options): AstroIntegration { allowOverwrite: true, format: 'esm', bundle: true, - minify: true, + minify: _config.vite?.build?.minify !== false, banner: { js: SHIM, }, |