Skip to content

Commit

Permalink
chore: load replace plugin on demand
Browse files Browse the repository at this point in the history
  • Loading branch information
userquin committed Oct 13, 2022
1 parent 9cc0dcc commit 38b50b4
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -70,7 +70,6 @@
"workbox-window": "^6.5.4"
},
"dependencies": {
"@rollup/plugin-replace": "^4.0.0",
"debug": "^4.3.4",
"fast-glob": "^3.2.11",
"pretty-bytes": "^6.0.0",
Expand All @@ -81,6 +80,7 @@
"devDependencies": {
"@antfu/eslint-config": "^0.26.3",
"@antfu/ni": "^0.18.0",
"@rollup/plugin-replace": "^4.0.0",
"@types/debug": "^4.1.7",
"@types/node": "^18.7.15",
"@types/prompts": "^2.4.0",
Expand Down
9 changes: 5 additions & 4 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion src/modules.ts
Expand Up @@ -3,7 +3,6 @@ import { promises as fs } from 'fs'
import { fileURLToPath } from 'url'
import type { BuildResult } from 'workbox-build'
import type { ResolvedConfig } from 'vite'
import replace from '@rollup/plugin-replace'
import type { ResolvedVitePWAOptions } from './types'
import { logWorkboxResult } from './log'
import { defaultInjectManifestVitePlugins } from './constants'
Expand Down Expand Up @@ -99,6 +98,8 @@ export async function generateInjectManifest(options: ResolvedVitePWAOptions, vi
if (includedPluginNames.length === 0)
includedPluginNames.push(...defaultInjectManifestVitePlugins)

const { default: replace } = await import('@rollup/plugin-replace')

const plugins = [
replace({
'preventAssignment': true,
Expand Down

0 comments on commit 38b50b4

Please sign in to comment.