@@ -6,6 +6,7 @@ const CopyWebpackPlugin = require('copy-webpack-plugin')
66const ChromeExtensionReloader = require ( 'webpack-chrome-extension-reloader' )
77const WebpackShellPlugin = require ( 'webpack-shell-plugin-next' )
88const HtmlWebpackPlugin = require ( 'html-webpack-plugin' )
9+ const ZipPlugin = require ( 'zip-webpack-plugin' )
910
1011const appRootPath = process . cwd ( )
1112
@@ -14,7 +15,7 @@ module.exports = (api) => {
1415 const isDevelopment = api . service . mode === 'development'
1516 const isProduction = api . service . mode === 'production'
1617 const outputDir = api . resolve ( api . service . projectOptions . outputDir || 'dist' )
17- const packageScript = isProduction ? 'build-zip.js' : 'remove-evals.js'
18+ const packageScript = isProduction ? null : 'remove-evals.js'
1819 const hasOptionsPageEntry = fs . existsSync ( api . resolve ( './src/options/options.js' ) )
1920 const hasKeyFile = fs . existsSync ( api . resolve ( 'key.pem' ) )
2021
@@ -103,13 +104,20 @@ module.exports = (api) => {
103104 } ) )
104105 }
105106
106- webpackConfig . plugins . push ( new WebpackShellPlugin ( {
107- onBuildExit : {
108- scripts : [ `node ${ path . join ( __dirname , 'scripts' , packageScript ) } ${ outputDir } ` ] ,
109- blocking : true ,
110- parallel : false
111- }
112- } ) )
107+ if ( packageScript === null ) {
108+ webpackConfig . plugins . push ( new ZipPlugin ( {
109+ path : api . resolve ( `${ api . service . projectOptions . outputDir || 'dist' } -zip` ) ,
110+ filename : `${ name } -v${ version } .zip`
111+ } ) )
112+ } else {
113+ webpackConfig . plugins . push ( new WebpackShellPlugin ( {
114+ onBuildExit : {
115+ scripts : [ `node ${ path . join ( __dirname , 'scripts' , packageScript ) } ${ outputDir } ` ] ,
116+ blocking : true ,
117+ parallel : false
118+ }
119+ } ) )
120+ }
113121
114122 if ( isDevelopment ) {
115123 webpackConfig . plugins = ( webpackConfig . plugins || [ ] ) . concat ( [
0 commit comments