Skip to content

Commit 617dd04

Browse files
authored
feat: improve compatibility with v3 plugin usage (#4664)
1. `public/manifest.json` will be used when no `pwa.manifestOptions` present; 2. warn user when there are both the file & the config field present.
1 parent e5196f5 commit 617dd04

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

packages/@vue/cli-plugin-pwa/index.js

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,27 @@
1+
const fs = require('fs')
2+
const { chalk, warn } = require('@vue/cli-shared-utils')
3+
14
module.exports = (api, options) => {
5+
const userOptions = options.pwa || {}
6+
7+
const manifestPath = api.resolve('public/manifest.json')
8+
if (fs.existsSync(manifestPath)) {
9+
if (!userOptions.manifestOptions) {
10+
userOptions.manifestOptions = require(manifestPath)
11+
} else {
12+
warn(
13+
`The ${chalk.red('public/manifest.json')} file will be ignored in favor of ${chalk.cyan('pwa.manifestOptions')}`
14+
)
15+
}
16+
}
17+
218
api.chainWebpack(webpackConfig => {
319
const target = process.env.VUE_CLI_BUILD_TARGET
420
if (target && target !== 'app') {
521
return
622
}
723

824
const name = api.service.pkg.name
9-
const userOptions = options.pwa || {}
1025

1126
// the pwa plugin hooks on to html-webpack-plugin
1227
// and injects icons, manifest links & other PWA related tags into <head>

0 commit comments

Comments
 (0)