mirror of
https://github.com/vuejs/vue-cli.git
synced 2026-05-19 12:08:27 -05:00
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:
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user