@@ -5,13 +5,17 @@ const logger = require('@vue/cli-shared-utils')
55const webpack = require ( 'webpack' )
66const CopyWebpackPlugin = require ( 'copy-webpack-plugin' )
77const ZipPlugin = require ( 'zip-webpack-plugin' )
8- const defaultOptions = { components : { } , componentOptions : { } }
8+ const defaultOptions = {
9+ components : { } ,
10+ componentOptions : { } ,
11+ manifestSync : [ 'version' ]
12+ }
913
1014module . exports = ( api , options ) => {
1115 const appRootPath = api . getCwd ( )
1216 const pluginOptions = options . pluginOptions . browserExtension ? options . pluginOptions . browserExtension : defaultOptions
1317 const componentOptions = pluginOptions . componentOptions
14- const { name , version } = require ( path . join ( appRootPath , 'package.json' ) )
18+ const packageJson = require ( path . join ( appRootPath , 'package.json' ) )
1519 const isDevelopment = api . service . mode === 'development'
1620 const isProduction = api . service . mode === 'production'
1721 const keyFile = api . resolve ( 'key.pem' )
@@ -73,7 +77,12 @@ module.exports = (api, options) => {
7377 transform : ( content ) => {
7478 return new Promise ( ( resolve , reject ) => {
7579 const jsonContent = JSON . parse ( content )
76- jsonContent . version = version
80+ if ( options . manifestSync . includes ( 'version' ) ) {
81+ jsonContent . version = packageJson . version
82+ }
83+ if ( options . manifestSync . includes ( 'description' ) ) {
84+ jsonContent . description = packageJson . description
85+ }
7786
7887 if ( isProduction ) {
7988 return resolve ( JSON . stringify ( jsonContent , null , 2 ) )
@@ -106,7 +115,7 @@ module.exports = (api, options) => {
106115 if ( isProduction ) {
107116 webpackConfig . plugins . push ( new ZipPlugin ( {
108117 path : api . resolve ( `${ options . outputDir || 'dist' } -zip` ) ,
109- filename : `${ name } -v${ version } .zip`
118+ filename : `${ packageJson . name } -v${ packageJson . version } .zip`
110119 } ) )
111120 }
112121
0 commit comments