Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Service Worker fails in dev if using vue-18n with runtimeOnly flag set to false #472

Closed
Polm90 opened this issue Feb 15, 2023 · 0 comments
Closed

Comments

@Polm90
Copy link

Polm90 commented Feb 15, 2023

If I configure the VueI18nPlugin with the runtimeOnly flag to false, I cannot run in dev mode a service worker injected with the vite-plugin-pwa plugin with strategy 'injectManifest'. I receive as error 'cannot use import statement outside a module'.

Setting the flag to true, everything works as expected.
However, with the flag set to true, the named interpolation is not working when the app is built. See this intlify/vue-i18n#1278

Custom service worker file:

import` {precacheAndRoute} from 'workbox-precaching';

precacheAndRoute(self.__WB_MANIFEST);

vite.config.js plugins configuration:

VueI18nPlugin({
			include: resolve(dirname(fileURLToPath(import.meta.url)), './src/locales/**'),
			runtimeOnly: false
		}),
		VitePWA({
			injectRegister: 'auto',
			registerType: 'prompt',
			devOptions: {
				enabled: true,
				type: 'module'
			},
			workbox: {
				globPatterns: ['**/*.{js,css,html,json,ico,svg,ttf,webmanifest}'],
			},
			srcDir: '',
			filename: 'custom-sw.js',
			strategies: 'injectManifest',
			includeAssets: ['favicon.ico', 'apple-icon-180.png', '**/*.{js,css,html,json,ico,svg,ttf,webmanifest}'],
			manifest: {
				//omitted
			}
		})

System info:

vite: 4.1.1
vue: 3.2.47
node: 19.6.0
npm: 9.4.2
@intlify/unplugin-vue-i18n: 0.8.2
vue-i18n: 9.2.2
vite-plugin-pwa: 0.14.4
workbox-precaching: 6.5.4

You can also see: intlify/vue-i18n#1333

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants