Skip to content

Commit 143ca01

Browse files
committed
Removing homemade zip script in favor of webpack zip plugin
1 parent cae9d52 commit 143ca01

File tree

3 files changed

+30
-51
lines changed

3 files changed

+30
-51
lines changed

index.js

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ const CopyWebpackPlugin = require('copy-webpack-plugin')
66
const ChromeExtensionReloader = require('webpack-chrome-extension-reloader')
77
const WebpackShellPlugin = require('webpack-shell-plugin-next')
88
const HtmlWebpackPlugin = require('html-webpack-plugin')
9+
const ZipPlugin = require('zip-webpack-plugin')
910

1011
const 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([

scripts/build-zip.js

Lines changed: 0 additions & 42 deletions
This file was deleted.

yarn.lock

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -511,7 +511,7 @@ browserify-zlib@^0.2.0:
511511
dependencies:
512512
pako "~1.0.5"
513513

514-
buffer-crc32@~0.2.1:
514+
buffer-crc32@~0.2.1, buffer-crc32@~0.2.3:
515515
version "0.2.13"
516516
resolved "https://registry.yarnpkg.com/buffer-crc32/-/buffer-crc32-0.2.13.tgz#0d333e3f00eac50aa1454abd30ef8c2a5d9a7242"
517517

@@ -3819,6 +3819,12 @@ yallist@^3.0.0, yallist@^3.0.2:
38193819
version "3.0.2"
38203820
resolved "https://registry.yarnpkg.com/yallist/-/yallist-3.0.2.tgz#8452b4bb7e83c7c188d8041c1a837c773d6d8bb9"
38213821

3822+
yazl@^2.4.3:
3823+
version "2.4.3"
3824+
resolved "https://registry.yarnpkg.com/yazl/-/yazl-2.4.3.tgz#ec26e5cc87d5601b9df8432dbdd3cd2e5173a071"
3825+
dependencies:
3826+
buffer-crc32 "~0.2.3"
3827+
38223828
zip-folder@^1.0.0:
38233829
version "1.0.0"
38243830
resolved "https://registry.yarnpkg.com/zip-folder/-/zip-folder-1.0.0.tgz#70a7744fd1789a2feb41ad3419b32e9fd87957b2"
@@ -3832,3 +3838,10 @@ zip-stream@~0.4.0:
38323838
compress-commons "~0.1.0"
38333839
lodash "~2.4.1"
38343840
readable-stream "~1.0.26"
3841+
3842+
zip-webpack-plugin@^3.0.0:
3843+
version "3.0.0"
3844+
resolved "https://registry.yarnpkg.com/zip-webpack-plugin/-/zip-webpack-plugin-3.0.0.tgz#63b3c173f1a87a006915cd7328a3c40b44dc8e32"
3845+
dependencies:
3846+
webpack-sources "^1.1.0"
3847+
yazl "^2.4.3"

0 commit comments

Comments
 (0)