Skip to content

Commit 6e56f6f

Browse files
committed
Added zipping dist folder into build process
1 parent 7088457 commit 6e56f6f

File tree

6 files changed

+162
-9
lines changed

6 files changed

+162
-9
lines changed

generator/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
module.exports = (api, { config }) => {
22
const eslintConfig = { env: { webextensions: true } }
33
const pkg = {
4+
private: true,
45
scripts: {
56
'ext-serve': 'vue-cli-service ext-serve --mode development'
67
},

index.js

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,20 @@
11
const path = require('path')
22
const fs = require('fs')
33
const { exec } = require('child_process')
4-
const isProduction = process.env.NODE_ENV === 'production'
5-
const appRootPath = process.cwd()
64
const { log } = require('@vue/cli-shared-utils')
75
const CopyWebpackPlugin = require('copy-webpack-plugin')
86
const ChromeExtensionReloader = require('webpack-chrome-extension-reloader')
97
const WebpackShellPlugin = require('webpack-shell-plugin-next')
108
const HtmlWebpackPlugin = require('html-webpack-plugin')
11-
const { name, version } = require(path.join(appRootPath, 'package.json'))
9+
10+
const appRootPath = process.cwd()
1211

1312
module.exports = (api) => {
13+
const { name, version } = require(path.join(appRootPath, 'package.json'))
14+
const isDevelopment = api.service.mode === 'development'
15+
const isProduction = api.service.mode === 'production'
16+
const packageScript = isProduction ? 'build-zip.js' : 'remove-evals.js'
17+
1418
api.configureWebpack(webpackConfig => {
1519
webpackConfig.output.filename = '[name].js'
1620
webpackConfig.output.chunkFilename = 'js/[id].[name].js?[hash:8]'
@@ -71,16 +75,15 @@ module.exports = (api) => {
7175
chunks: ['popup/popup', 'chunk-vendors']
7276
}))
7377

74-
const scriptPath = path.join(__dirname, 'scripts/remove-evals.js')
7578
webpackConfig.plugins.push(new WebpackShellPlugin({
7679
onBuildExit: {
77-
scripts: [`node ${scriptPath}`],
80+
scripts: [`node ${path.join(__dirname, 'scripts', packageScript)}`],
7881
blocking: true,
7982
parallel: false
8083
}
8184
}))
8285

83-
if (process.env.NODE_ENV === 'development') {
86+
if (isDevelopment) {
8487
webpackConfig.plugins = (webpackConfig.plugins || []).concat([
8588
new ChromeExtensionReloader({
8689
entries: {

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
"html-webpack-plugin": "^3.2.0",
3030
"webpack": "^4.16.0",
3131
"webpack-chrome-extension-reloader": "^0.8.3",
32-
"webpack-shell-plugin-next": "https://github.com/adambullmer/webpack-shell-plugin-next.git"
32+
"webpack-shell-plugin-next": "https://github.com/adambullmer/webpack-shell-plugin-next.git",
33+
"zip-folder": "^1.0.0"
3334
}
3435
}

scripts/build-zip.js

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#!/usr/bin/env node
2+
3+
const fs = require('fs')
4+
const path = require('path')
5+
const zipFolder = require('zip-folder')
6+
7+
const appRootPath = process.cwd()
8+
const DEST_DIR = path.join(appRootPath, 'dist')
9+
const DEST_ZIP_DIR = path.join(appRootPath, 'dist-zip')
10+
const { name, version } = require(path.join(appRootPath, 'package.json'))
11+
12+
const makeDestZipDirIfNotExists = () => {
13+
if (!fs.existsSync(DEST_ZIP_DIR)) {
14+
fs.mkdirSync(DEST_ZIP_DIR)
15+
}
16+
}
17+
18+
const buildZip = (src, dist, zipFilename) => {
19+
console.info(`Building ${zipFilename}...`)
20+
21+
return new Promise((resolve, reject) => {
22+
zipFolder(src, path.join(dist, zipFilename), (err) => {
23+
if (err) {
24+
reject(err)
25+
} else {
26+
resolve()
27+
}
28+
})
29+
})
30+
}
31+
32+
const main = () => {
33+
const zipFilename = `${name}-v${version}.zip`
34+
35+
makeDestZipDirIfNotExists()
36+
37+
buildZip(DEST_DIR, DEST_ZIP_DIR, zipFilename)
38+
.then(() => console.info('OK'))
39+
.catch(console.err)
40+
}
41+
42+
main()

scripts/remove-evals.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
const path = require('path')
44
const fs = require('fs')
5-
const BUNDLE_DIR = 'dist'
5+
const BUNDLE_DIR = path.join(process.cwd(), 'dist')
66
const bundles = [
77
'background.js',
88
'popup/popup.js'

yarn.lock

Lines changed: 107 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,19 @@ aproba@^1.0.3, aproba@^1.1.1:
247247
version "1.2.0"
248248
resolved "https://registry.yarnpkg.com/aproba/-/aproba-1.2.0.tgz#6802e6264efd18c790a1b0d517f0f2627bf2c94a"
249249

250+
archiver@^0.11.0:
251+
version "0.11.0"
252+
resolved "https://registry.yarnpkg.com/archiver/-/archiver-0.11.0.tgz#98177da7a6c0192b7f2798f30cd6eab8abd76690"
253+
dependencies:
254+
async "~0.9.0"
255+
buffer-crc32 "~0.2.1"
256+
glob "~3.2.6"
257+
lazystream "~0.1.0"
258+
lodash "~2.4.1"
259+
readable-stream "~1.0.26"
260+
tar-stream "~0.4.0"
261+
zip-stream "~0.4.0"
262+
250263
are-we-there-yet@~1.1.2:
251264
version "1.1.5"
252265
resolved "https://registry.yarnpkg.com/are-we-there-yet/-/are-we-there-yet-1.1.5.tgz#4b35c2944f062a8bfcda66410760350fe9ddfc21"
@@ -324,6 +337,10 @@ async-limiter@~1.0.0:
324337
version "1.0.0"
325338
resolved "https://registry.yarnpkg.com/async-limiter/-/async-limiter-1.0.0.tgz#78faed8c3d074ab81f22b4e985d79e8738f720f8"
326339

340+
async@~0.9.0:
341+
version "0.9.2"
342+
resolved "https://registry.yarnpkg.com/async/-/async-0.9.2.tgz#aea74d5e61c1f899613bf64bda66d4c78f2fd17d"
343+
327344
asynckit@^0.4.0:
328345
version "0.4.0"
329346
resolved "https://registry.yarnpkg.com/asynckit/-/asynckit-0.4.0.tgz#c79ed97f7f34cb8f2ba1bc9790bcc366474b4b79"
@@ -397,6 +414,12 @@ binary-extensions@^1.0.0:
397414
version "1.11.0"
398415
resolved "https://registry.yarnpkg.com/binary-extensions/-/binary-extensions-1.11.0.tgz#46aa1751fb6a2f93ee5e689bb1087d4b14c6c205"
399416

417+
bl@^0.9.0:
418+
version "0.9.5"
419+
resolved "https://registry.yarnpkg.com/bl/-/bl-0.9.5.tgz#c06b797af085ea00bc527afc8efcf11de2232054"
420+
dependencies:
421+
readable-stream "~1.0.26"
422+
400423
bluebird@^3.5.1:
401424
version "3.5.1"
402425
resolved "https://registry.yarnpkg.com/bluebird/-/bluebird-3.5.1.tgz#d9551f9de98f1fcda1e683d17ee91a0602ee2eb9"
@@ -488,6 +511,10 @@ browserify-zlib@^0.2.0:
488511
dependencies:
489512
pako "~1.0.5"
490513

514+
buffer-crc32@~0.2.1:
515+
version "0.2.13"
516+
resolved "https://registry.yarnpkg.com/buffer-crc32/-/buffer-crc32-0.2.13.tgz#0d333e3f00eac50aa1454abd30ef8c2a5d9a7242"
517+
491518
buffer-from@^1.0.0:
492519
version "1.1.0"
493520
resolved "https://registry.yarnpkg.com/buffer-from/-/buffer-from-1.1.0.tgz#87fcaa3a298358e0ade6e442cfce840740d1ad04"
@@ -707,6 +734,14 @@ component-emitter@^1.2.1:
707734
version "1.2.1"
708735
resolved "https://registry.yarnpkg.com/component-emitter/-/component-emitter-1.2.1.tgz#137918d6d78283f7df7a6b7c5a63e140e69425e6"
709736

737+
compress-commons@~0.1.0:
738+
version "0.1.6"
739+
resolved "https://registry.yarnpkg.com/compress-commons/-/compress-commons-0.1.6.tgz#0c740870fde58cba516f0ac0c822e33a0b85dfa3"
740+
dependencies:
741+
buffer-crc32 "~0.2.1"
742+
crc32-stream "~0.3.1"
743+
readable-stream "~1.0.26"
744+
710745
concat-map@0.0.1:
711746
version "0.0.1"
712747
resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b"
@@ -774,6 +809,13 @@ core-util-is@1.0.2, core-util-is@~1.0.0:
774809
version "1.0.2"
775810
resolved "https://registry.yarnpkg.com/core-util-is/-/core-util-is-1.0.2.tgz#b5fd54220aa2bc5ab57aab7140c940754503c1a7"
776811

812+
crc32-stream@~0.3.1:
813+
version "0.3.4"
814+
resolved "https://registry.yarnpkg.com/crc32-stream/-/crc32-stream-0.3.4.tgz#73bc25b45fac1db6632231a7bfce8927e9f06552"
815+
dependencies:
816+
buffer-crc32 "~0.2.1"
817+
readable-stream "~1.0.24"
818+
777819
create-ecdh@^4.0.0:
778820
version "4.0.3"
779821
resolved "https://registry.yarnpkg.com/create-ecdh/-/create-ecdh-4.0.3.tgz#c9111b6f33045c4697f144787f9254cdc77c45ff"
@@ -1527,6 +1569,13 @@ glob@^7.0.3, glob@^7.0.5, glob@^7.1.2:
15271569
once "^1.3.0"
15281570
path-is-absolute "^1.0.0"
15291571

1572+
glob@~3.2.6:
1573+
version "3.2.11"
1574+
resolved "https://registry.yarnpkg.com/glob/-/glob-3.2.11.tgz#4a973f635b9190f715d10987d5c00fd2815ebe3d"
1575+
dependencies:
1576+
inherits "2"
1577+
minimatch "0.3"
1578+
15301579
globals@^11.7.0:
15311580
version "11.7.0"
15321581
resolved "https://registry.yarnpkg.com/globals/-/globals-11.7.0.tgz#a583faa43055b1aca771914bf68258e2fc125673"
@@ -2055,6 +2104,12 @@ kind-of@^6.0.0, kind-of@^6.0.2:
20552104
version "6.0.2"
20562105
resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-6.0.2.tgz#01146b36a6218e64e58f3a8d66de5d7fc6f6d051"
20572106

2107+
lazystream@~0.1.0:
2108+
version "0.1.0"
2109+
resolved "https://registry.yarnpkg.com/lazystream/-/lazystream-0.1.0.tgz#1b25d63c772a4c20f0a5ed0a9d77f484b6e16920"
2110+
dependencies:
2111+
readable-stream "~1.0.2"
2112+
20582113
levn@^0.3.0, levn@~0.3.0:
20592114
version "0.3.0"
20602115
resolved "https://registry.yarnpkg.com/levn/-/levn-0.3.0.tgz#3b09924edf9f083c0490fdd4c0bc4421e04764ee"
@@ -2107,6 +2162,10 @@ lodash@^4.13.1, lodash@^4.17.3, lodash@^4.17.4, lodash@^4.17.5, lodash@^4.3.0:
21072162
version "4.17.10"
21082163
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.10.tgz#1b7793cf7259ea38fb3661d4d38b3260af8ae4e7"
21092164

2165+
lodash@~2.4.1:
2166+
version "2.4.2"
2167+
resolved "https://registry.yarnpkg.com/lodash/-/lodash-2.4.2.tgz#fadd834b9683073da179b3eae6d9c0d15053f73e"
2168+
21102169
log-symbols@^2.1.0:
21112170
version "2.2.0"
21122171
resolved "https://registry.yarnpkg.com/log-symbols/-/log-symbols-2.2.0.tgz#5740e1c5d6f0dfda4ad9323b5332107ef6b4c40a"
@@ -2125,6 +2184,10 @@ lower-case@^1.1.1:
21252184
version "1.1.4"
21262185
resolved "https://registry.yarnpkg.com/lower-case/-/lower-case-1.1.4.tgz#9a2cabd1b9e8e0ae993a4bf7d5875c39c42e8eac"
21272186

2187+
lru-cache@2:
2188+
version "2.7.3"
2189+
resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-2.7.3.tgz#6d4524e8b955f95d4f5b58851ce21dd72fb4e952"
2190+
21282191
lru-cache@^4.1.1:
21292192
version "4.1.3"
21302193
resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-4.1.3.tgz#a1175cf3496dfc8436c156c334b4955992bce69c"
@@ -2213,6 +2276,13 @@ minimalistic-crypto-utils@^1.0.0, minimalistic-crypto-utils@^1.0.1:
22132276
version "1.0.1"
22142277
resolved "https://registry.yarnpkg.com/minimalistic-crypto-utils/-/minimalistic-crypto-utils-1.0.1.tgz#f6c00c1c0b082246e5c4d99dfb8c7c083b2b582a"
22152278

2279+
minimatch@0.3:
2280+
version "0.3.0"
2281+
resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-0.3.0.tgz#275d8edaac4f1bb3326472089e7949c8394699dd"
2282+
dependencies:
2283+
lru-cache "2"
2284+
sigmund "~1.0.0"
2285+
22162286
minimatch@^3.0.2, minimatch@^3.0.3, minimatch@^3.0.4:
22172287
version "3.0.4"
22182288
resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.0.4.tgz#5166e286457f03306064be5497e8dbb0c3d32083"
@@ -2831,7 +2901,7 @@ read-pkg@^2.0.0:
28312901
string_decoder "~1.1.1"
28322902
util-deprecate "~1.0.1"
28332903

2834-
readable-stream@1.0:
2904+
readable-stream@1.0, readable-stream@~1.0.2, readable-stream@~1.0.24, readable-stream@~1.0.26:
28352905
version "1.0.34"
28362906
resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-1.0.34.tgz#125820e34bc842d2f2aaafafe4c2916ee32c157c"
28372907
dependencies:
@@ -2840,6 +2910,15 @@ readable-stream@1.0:
28402910
isarray "0.0.1"
28412911
string_decoder "~0.10.x"
28422912

2913+
readable-stream@^1.0.27-1:
2914+
version "1.1.14"
2915+
resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-1.1.14.tgz#7cf4c54ef648e3813084c636dd2079e166c081d9"
2916+
dependencies:
2917+
core-util-is "~1.0.0"
2918+
inherits "~2.0.1"
2919+
isarray "0.0.1"
2920+
string_decoder "~0.10.x"
2921+
28432922
readdirp@^2.0.0:
28442923
version "2.1.0"
28452924
resolved "https://registry.yarnpkg.com/readdirp/-/readdirp-2.1.0.tgz#4ed0ad060df3073300c48440373f72d1cc642d78"
@@ -3082,6 +3161,10 @@ shebang-regex@^1.0.0:
30823161
version "1.0.0"
30833162
resolved "https://registry.yarnpkg.com/shebang-regex/-/shebang-regex-1.0.0.tgz#da42f49740c0b42db2ca9728571cb190c98efea3"
30843163

3164+
sigmund@~1.0.0:
3165+
version "1.0.1"
3166+
resolved "https://registry.yarnpkg.com/sigmund/-/sigmund-1.0.1.tgz#3ff21f198cad2175f9f3b781853fd94d0d19b590"
3167+
30853168
signal-exit@^3.0.0, signal-exit@^3.0.2:
30863169
version "3.0.2"
30873170
resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-3.0.2.tgz#b5fdc08f1287ea1178628e415e25132b73646c6d"
@@ -3337,6 +3420,15 @@ tapable@^1.0.0:
33373420
version "1.0.0"
33383421
resolved "https://registry.yarnpkg.com/tapable/-/tapable-1.0.0.tgz#cbb639d9002eed9c6b5975eb20598d7936f1f9f2"
33393422

3423+
tar-stream@~0.4.0:
3424+
version "0.4.7"
3425+
resolved "https://registry.yarnpkg.com/tar-stream/-/tar-stream-0.4.7.tgz#1f1d2ce9ebc7b42765243ca0e8f1b7bfda0aadcd"
3426+
dependencies:
3427+
bl "^0.9.0"
3428+
end-of-stream "^1.0.0"
3429+
readable-stream "^1.0.27-1"
3430+
xtend "^4.0.0"
3431+
33403432
tar@^4:
33413433
version "4.4.4"
33423434
resolved "https://registry.yarnpkg.com/tar/-/tar-4.4.4.tgz#ec8409fae9f665a4355cc3b4087d0820232bb8cd"
@@ -3726,3 +3818,17 @@ yallist@^2.1.2:
37263818
yallist@^3.0.0, yallist@^3.0.2:
37273819
version "3.0.2"
37283820
resolved "https://registry.yarnpkg.com/yallist/-/yallist-3.0.2.tgz#8452b4bb7e83c7c188d8041c1a837c773d6d8bb9"
3821+
3822+
zip-folder@^1.0.0:
3823+
version "1.0.0"
3824+
resolved "https://registry.yarnpkg.com/zip-folder/-/zip-folder-1.0.0.tgz#70a7744fd1789a2feb41ad3419b32e9fd87957b2"
3825+
dependencies:
3826+
archiver "^0.11.0"
3827+
3828+
zip-stream@~0.4.0:
3829+
version "0.4.1"
3830+
resolved "https://registry.yarnpkg.com/zip-stream/-/zip-stream-0.4.1.tgz#4ea795a8ce19e9fab49a31d1d0877214159f03a3"
3831+
dependencies:
3832+
compress-commons "~0.1.0"
3833+
lodash "~2.4.1"
3834+
readable-stream "~1.0.26"

0 commit comments

Comments
 (0)