astro: Unexpected behaviour when using cloudflare deploy adapter

When I use @astrojs/cloudflare as deploy adapter in adapter field of astro config, all the files generated by vite-pwa are available in dist/_worker.js directory instead of dist.

"astro": "^5.7.9"
"@astrojs/cloudflare": "^12.5.1"
"@vite-pwa/astro": "^1.0.1"
"vite-plugin-pwa": "^1.0.0"

astro.config.ts:

import cloudflare from '@astrojs/cloudflare';
import AstroPWA from '@vite-pwa/astro';
import { defineConfig } from 'astro/config';

// https://astro.build/config
export default defineConfig({
  adapter: cloudflare(),
  trailingSlash: 'never',
  integrations: [
    AstroPWA({
      registerType: 'autoUpdate',
      manifest: {
        name: "App",
        short_name: "App",
        icons: []
      },
      workbox: {
        globDirectory: 'dist',
        globPatterns: ['**/*.{js,css,svg,png,jpg,jpeg,gif,webp,woff,woff2,ttf,eot,ico}'],
        globIgnores: ['**/_worker.js/**/*'],
        // Don't fallback on document based (e.g. `/some-page`) requests
        // This removes an errant console.log message from showing up.
        navigateFallback: null,
      },
      experimental: {
        directoryAndTrailingSlashHandler: true,
      },
    }),
  ],
});

When removing @astrojs/cloudflare adapter, the files are generated in dist

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 15 (8 by maintainers)

Most upvoted comments

Thanks! After adding pwa.ts and installing workbox-window dependency, it is emitting all the files to dist.

Also, I am sorry since it works in current version too after doing so.

Sorry for the trouble and wasting your time.

In pkg.pr.new, the files are emitted to client code only which is expected.

After reinstalling the dependency, only service worker js (sw.js and workbox-*.js) is moved to dist but other files (manifest.webmanifest, registerSW.js, etc) are still being generated in dist/_worker.js dir