Skip to content

Commit

Permalink
feat: Vite 5 support (#585)
Browse files Browse the repository at this point in the history
  • Loading branch information
userquin authored Oct 27, 2023
1 parent 51dc858 commit ee96626
Show file tree
Hide file tree
Showing 14 changed files with 424 additions and 447 deletions.
4 changes: 2 additions & 2 deletions examples/preact-router/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,12 @@
"preact-router": "^4.1.2"
},
"devDependencies": {
"@preact/preset-vite": "^2.5.0",
"@preact/preset-vite": "^2.6.0",
"@rollup/plugin-replace": "^5.0.2",
"https-localhost": "^4.7.1",
"rimraf": "^5.0.1",
"typescript": "^5.2.2",
"vite": "^4.0.0",
"vite": "^4.5.0",
"vite-plugin-pwa": "workspace:*",
"workbox-core": "^7.0.0",
"workbox-precaching": "^7.0.0",
Expand Down
7 changes: 0 additions & 7 deletions examples/preact-router/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,7 @@ const pwaOptions: Partial<VitePWAOptions> = {
},
}

const replaceOptions = { __DATE__: new Date().toISOString() }
const claims = process.env.CLAIMS === 'true'
const reload = process.env.RELOAD_SW === 'true'
const selfDestroying = process.env.SW_DESTROY === 'true'

if (process.env.SW === 'true') {
Expand All @@ -56,11 +54,6 @@ if (process.env.SW === 'true') {
if (claims)
pwaOptions.registerType = 'autoUpdate'

if (reload) {
// @ts-expect-error just ignore
replaceOptions.__RELOAD_SW__ = 'true'
}

if (selfDestroying)
pwaOptions.selfDestroying = selfDestroying

Expand Down
4 changes: 2 additions & 2 deletions examples/react-router/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,11 @@
"@types/react-dom": "^18.2.7",
"@types/react-router-config": "^5.0.7",
"@types/react-router-dom": "^5.3.3",
"@vitejs/plugin-react": "^4.0.4",
"@vitejs/plugin-react": "^4.1.0",
"https-localhost": "^4.7.1",
"rimraf": "^5.0.1",
"typescript": "^5.2.2",
"vite": "^4.0.0",
"vite": "^4.5.0",
"vite-plugin-pwa": "workspace:*",
"workbox-core": "^7.0.0",
"workbox-precaching": "^7.0.0",
Expand Down
4 changes: 2 additions & 2 deletions examples/solid-router/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@
"https-localhost": "^4.7.1",
"rimraf": "^5.0.1",
"typescript": "^5.2.2",
"vite": "^4.0.0",
"vite": "^4.5.0",
"vite-plugin-pwa": "workspace:*",
"vite-plugin-solid": "^2.7.0",
"vite-plugin-solid": "^2.7.2",
"workbox-core": "^7.0.0",
"workbox-precaching": "^7.0.0",
"workbox-routing": "^7.0.0",
Expand Down
14 changes: 5 additions & 9 deletions examples/solid-router/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,7 @@ const pwaOptions: Partial<VitePWAOptions> = {
},
}

const replaceOptions = { __DATE__: new Date().toISOString() }
const claims = process.env.CLAIMS === 'true'
const reload = process.env.RELOAD_SW === 'true'
const selfDestroying = process.env.SW_DESTROY === 'true'

if (process.env.SW === 'true') {
Expand All @@ -56,23 +54,21 @@ if (process.env.SW === 'true') {
if (claims)
pwaOptions.registerType = 'autoUpdate'

if (reload) {
// @ts-expect-error just ignore
replaceOptions.__RELOAD_SW__ = 'true'
}

if (selfDestroying)
pwaOptions.selfDestroying = selfDestroying

export default defineConfig({
build: {
sourcemap: process.env.SOURCE_MAP === 'true',
target: 'esnext',
polyfillDynamicImport: false,
// polyfillDynamicImport: false,
},
plugins: [
solidPlugin(),
VitePWA(pwaOptions),
replace(replaceOptions),
replace({
__DATE__: new Date().toISOString(),
__RELOAD_SW__: process.env.RELOAD_SW === 'true' ? 'true' : 'false',
}),
],
})
6 changes: 3 additions & 3 deletions examples/svelte-routify/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,17 +50,17 @@
"devDependencies": {
"@rollup/plugin-replace": "^5.0.2",
"@roxi/routify": "^2.18.12",
"@sveltejs/vite-plugin-svelte": "^2.4.5",
"@sveltejs/vite-plugin-svelte": "^2.4.6",
"@tsconfig/svelte": "^5.0.2",
"eslint": "^8.48.0",
"eslint-plugin-svelte3": "^4.0.0",
"https-localhost": "^4.7.1",
"rimraf": "^5.0.1",
"svelte": "^4.2.0",
"svelte-check": "^3.5.1",
"svelte-check": "^3.5.2",
"svelte-preprocess": "^5.0.4",
"typescript": "^5.2.2",
"vite": "^4.0.0",
"vite": "^4.5.0",
"vite-plugin-pwa": "workspace:*",
"workbox-core": "^7.0.0",
"workbox-precaching": "^7.0.0",
Expand Down
13 changes: 5 additions & 8 deletions examples/svelte-routify/vite.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { defineConfig } from 'vite'
import { svelte } from '@sveltejs/vite-plugin-svelte'
import { VitePWA } from 'vite-plugin-pwa'
import replace from '@rollup/plugin-replace'
import process from "node:process";

const pwaOptions = {
mode: 'development',
Expand Down Expand Up @@ -38,9 +39,7 @@ const pwaOptions = {
},
}

const replaceOptions = { __DATE__: new Date().toISOString() }
const claims = process.env.CLAIMS === 'true'
const reload = process.env.RELOAD_SW === 'true'
const selfDestroying = process.env.SW_DESTROY === 'true'

if (process.env.SW === 'true') {
Expand All @@ -54,11 +53,6 @@ if (process.env.SW === 'true') {
if (claims)
pwaOptions.registerType = 'autoUpdate'

if (reload) {
// @ts-ignore
replaceOptions.__RELOAD_SW__ = 'true'
}

if (selfDestroying)
pwaOptions.selfDestroying = selfDestroying

Expand All @@ -70,7 +64,10 @@ export default defineConfig({
plugins: [
svelte(),
VitePWA(pwaOptions),
replace(replaceOptions),
replace({
__DATE__: new Date().toISOString(),
__RELOAD_SW__: process.env.RELOAD_SW === 'true' ? 'true' : 'false',
}),
],
})

2 changes: 1 addition & 1 deletion examples/vanilla-ts-dev-options/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"devDependencies": {
"rimraf": "^5.0.1",
"typescript": "^5.2.2",
"vite": "^4.0.0",
"vite": "^4.5.0",
"vite-plugin-pwa": "workspace:*"
}
}
2 changes: 1 addition & 1 deletion examples/vanilla-ts-no-ip/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"devDependencies": {
"rimraf": "^5.0.1",
"typescript": "^5.2.2",
"vite": "^4.0.0",
"vite": "^4.5.0",
"vite-plugin-pwa": "workspace:*",
"workbox-cacheable-response": "^7.0.0",
"workbox-core": "^7.0.0",
Expand Down
2 changes: 1 addition & 1 deletion examples/vue-basic-cdn/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"@vueuse/core": "^10.4.1",
"https-localhost": "^4.7.1",
"typescript": "^5.2.2",
"vite": "^4.0.0",
"vite": "^4.5.0",
"vite-plugin-pwa": "workspace:*"
}
}
4 changes: 2 additions & 2 deletions examples/vue-router/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,12 @@
},
"devDependencies": {
"@rollup/plugin-replace": "^5.0.2",
"@vitejs/plugin-vue": "^4.3.4",
"@vitejs/plugin-vue": "^4.4.0",
"@vueuse/core": "^10.4.1",
"https-localhost": "^4.7.1",
"rimraf": "^5.0.1",
"typescript": "^5.2.2",
"vite": "^4.0.0",
"vite": "^4.5.0",
"vite-plugin-pwa": "workspace:*",
"workbox-core": "^7.0.0",
"workbox-precaching": "^7.0.0",
Expand Down
12 changes: 4 additions & 8 deletions examples/vue-router/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,7 @@ const pwaOptions: Partial<VitePWAOptions> = {
},
}

const replaceOptions = { __DATE__: new Date().toISOString() }
const claims = process.env.CLAIMS === 'true'
const reload = process.env.RELOAD_SW === 'true'
const selfDestroying = process.env.SW_DESTROY === 'true'

if (process.env.SW === 'true') {
Expand All @@ -57,11 +55,6 @@ if (process.env.SW === 'true') {
if (claims)
pwaOptions.registerType = 'autoUpdate'

if (reload) {
// @ts-expect-error overrides
replaceOptions.__RELOAD_SW__ = 'true'
}

if (selfDestroying)
pwaOptions.selfDestroying = selfDestroying

Expand All @@ -73,6 +66,9 @@ export default defineConfig({
plugins: [
Vue(),
VitePWA(pwaOptions),
replace(replaceOptions),
replace({
__DATE__: new Date().toISOString(),
__RELOAD_SW__: process.env.RELOAD_SW === 'true' ? 'true' : 'false',
}),
],
})
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@
"test:vite-ecosystem-ci": "nr test-typescript"
},
"peerDependencies": {
"vite": "^3.1.0 || ^4.0.0",
"vite": "^3.1.0 || ^4.0.0 || ^5.0.0-0",
"workbox-build": "^7.0.0",
"workbox-window": "^7.0.0"
},
Expand Down Expand Up @@ -131,7 +131,7 @@
"svelte": "^4.2.0",
"tsup": "^7.2.0",
"typescript": "^5.2.2",
"vite": "^4.0.0",
"vite": "^4.5.0",
"vitest": "^0.34.4",
"vue": "^3.3.4"
}
Expand Down
Loading

0 comments on commit ee96626

Please sign in to comment.