diff --git a/packages/@vue/cli-plugin-pwa/index.js b/packages/@vue/cli-plugin-pwa/index.js index 462fa81656..f8feae2256 100644 --- a/packages/@vue/cli-plugin-pwa/index.js +++ b/packages/@vue/cli-plugin-pwa/index.js @@ -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