@@ -9,14 +9,23 @@ const defaultOptions = {
99 components : { } ,
1010 componentOptions : { } ,
1111 manifestSync : [ 'version' ] ,
12- modesToZip : [ 'production' ]
12+ modesToZip : [ 'production' ] ,
13+ manifestTransformer : null
1314}
1415const performanceAssetFilterList = [
1516 ( file ) => ! ( / \. m a p $ / . test ( file ) ) ,
1617 ( file ) => ! file . endsWith ( '.zip' ) ,
1718 ( file ) => ! ( / ^ i c o n s \/ / . test ( file ) )
1819]
1920
21+ function getManifestJsonString ( pluginOptions , jsonContent ) {
22+ if ( pluginOptions . manifestTransformer ) {
23+ const jsonContentCopy = Object . assign ( { } , jsonContent ) ;
24+ jsonContent = pluginOptions . manifestTransformer ( jsonContentCopy )
25+ }
26+ return JSON . stringify ( jsonContent , null , 2 )
27+ }
28+
2029module . exports = ( api , options ) => {
2130 const appRootPath = api . getCwd ( )
2231 const pluginOptions = options . pluginOptions . browserExtension ? Object . assign ( defaultOptions , options . pluginOptions . browserExtension ) : defaultOptions
@@ -91,7 +100,7 @@ module.exports = (api, options) => {
91100 }
92101
93102 if ( isProduction ) {
94- return resolve ( JSON . stringify ( jsonContent , null , 2 ) )
103+ return resolve ( getManifestJsonString ( pluginOptions , jsonContent ) )
95104 }
96105
97106 jsonContent . content_security_policy = jsonContent . content_security_policy || "script-src 'self' 'unsafe-eval'; object-src 'self'"
@@ -106,11 +115,11 @@ module.exports = (api, options) => {
106115 }
107116
108117 jsonContent . key = stdout
109- resolve ( JSON . stringify ( jsonContent , null , 2 ) )
118+ resolve ( getManifestJsonString ( pluginOptions , jsonContent ) )
110119 } )
111120 } catch ( error ) {
112121 logger . warn ( 'No key.pem file found. This is fine for dev, however you may have problems publishing without one' )
113- resolve ( JSON . stringify ( jsonContent , null , 2 ) )
122+ resolve ( getManifestJsonString ( pluginOptions , jsonContent ) )
114123 }
115124 } )
116125 }
0 commit comments