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.
This commit is contained in:
Haoqun Jiang
2019-10-10 09:59:49 +08:00
committed by GitHub
parent e5196f581a
commit 617dd04cb4
+16 -1
View File
@@ -1,4 +1,20 @@
const fs = require('fs')
const { chalk, warn } = require('@vue/cli-shared-utils')
module.exports = (api, options) => {
const userOptions = options.pwa || {}
const manifestPath = api.resolve('public/manifest.json')
if (fs.existsSync(manifestPath)) {
if (!userOptions.manifestOptions) {
userOptions.manifestOptions = require(manifestPath)
} else {
warn(
`The ${chalk.red('public/manifest.json')} file will be ignored in favor of ${chalk.cyan('pwa.manifestOptions')}`
)
}
}
api.chainWebpack(webpackConfig => {
const target = process.env.VUE_CLI_BUILD_TARGET
if (target && target !== 'app') {
@@ -6,7 +22,6 @@ module.exports = (api, options) => {
}
const name = api.service.pkg.name
const userOptions = options.pwa || {}
// the pwa plugin hooks on to html-webpack-plugin
// and injects icons, manifest links & other PWA related tags into <head>