vite-plugin-pwa icon indicating copy to clipboard operation
vite-plugin-pwa copied to clipboard

sw.js not generated with Astro build

Open angelnext opened this issue 2 years ago • 2 comments

When doing astro build command sw.js is not being generated.

Astro version: 1.0.0-beta.64 vite-plugin-pwa version: 0.11.11 vite version: 2.9.13

My astro.config.mjs

import { defineConfig } from 'astro/config';
import { VitePWA } from 'vite-plugin-pwa';
import tailwind from '@astrojs/tailwind';

export default defineConfig({
	integrations: [tailwind()],
	vite: {
		plugins: [
			VitePWA({
				includeAssets: [
					'favicon.png',
					'robots.txt',
					'manifest.webmanifest',
					'assets/icons/*.png',
					'assets/icons/*.svg',
					'assets/fonts/Splash-Regular.ttf',
				],
				registerType: 'autoUpdate',
				manifest: {
					short_name: 'AngelNext',
					name: 'AngelNext',
					start_url: '/',
					icons: [
						{
							src: 'favicon.png',
							type: 'image/png',
							sizes: '500x500',
						},
					],
					background_color: '#111827',
					display: 'standalone',
					scope: '/',
					theme_color: '#111827',
					description: 'Portfolio website for AngelNext',
				},
			}),
		],
	},
});

angelnext avatar Jul 07 '22 15:07 angelnext

@AngelNext we're working on the Astro integration, the PR is ready to review on the Astro repo: https://github.com/withastro/astro/pull/3428

EDIT: I need to resolve conflicts on the PR, but I cannot resolve them every day, when Astro ppl want to include it, I'll fix the conflicts.

userquin avatar Jul 07 '22 15:07 userquin

Hey, for some reason sw.js will not be generated in Astro unless you are hoisting a client-side script inside your Layout.astro file or wherever the entry-point of your Astro site is. Simply add an empty script tag and sw.js will then be included in your dist bundle. This works for [email protected]

shaunchander avatar Sep 02 '22 20:09 shaunchander

Released initial version of astro integration: https://vite-pwa-org.netlify.app/frameworks/astro.html

userquin avatar Nov 08 '22 08:11 userquin