mirror of
https://github.com/chinchang/web-maker.git
synced 2025-07-09 16:06:21 +02:00
add extension packaging task
This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@ -8,4 +8,5 @@
|
||||
### Misc ###
|
||||
node_modules/
|
||||
*.map
|
||||
.sass-cache
|
||||
.sass-cache
|
||||
extension/
|
29
gulpfile.js
29
gulpfile.js
@ -10,6 +10,7 @@ const concat = require('gulp-concat');
|
||||
const babelMinify = require('babel-minify');
|
||||
const child_process = require('child_process');
|
||||
const merge = require('merge-stream');
|
||||
const zip = require('gulp-zip');
|
||||
|
||||
function minifyJs(fileName) {
|
||||
const content = fs.readFileSync(fileName, 'utf8');
|
||||
@ -152,6 +153,33 @@ gulp.task('generate-service-worker', function(callback) {
|
||||
);
|
||||
});
|
||||
|
||||
gulp.task('packageExtension', function() {
|
||||
child_process.execSync('cp -R app extension/');
|
||||
child_process.execSync('cp src/manifest.json extension');
|
||||
child_process.execSync('cp src/options.js extension');
|
||||
child_process.execSync('cp src/options.html extension');
|
||||
child_process.execSync('cp src/eventPage.js extension');
|
||||
child_process.execSync('cp src/icon-16.png extension');
|
||||
child_process.execSync(
|
||||
'rm -rf extension/service-worker.js extension/partials'
|
||||
);
|
||||
return merge(
|
||||
gulp
|
||||
.src('build/bundle.*.js')
|
||||
.pipe(rename('script.js'))
|
||||
.pipe(gulp.dest('extension')),
|
||||
gulp
|
||||
.src('build/vendor.*.js')
|
||||
.pipe(rename('vendor.js'))
|
||||
.pipe(gulp.dest('extension')),
|
||||
|
||||
gulp
|
||||
.src('extension/*')
|
||||
.pipe(zip('extension.zip'))
|
||||
.pipe(gulp.dest('./'))
|
||||
);
|
||||
});
|
||||
|
||||
gulp.task('cleanup', function() {
|
||||
return child_process.execSync('rm -rf build');
|
||||
});
|
||||
@ -165,6 +193,7 @@ gulp.task('release', function(callback) {
|
||||
'concatSwRegistration',
|
||||
'minify',
|
||||
'generate-service-worker',
|
||||
'packageExtension',
|
||||
'cleanup',
|
||||
function(error) {
|
||||
if (error) {
|
||||
|
@ -35,6 +35,7 @@
|
||||
"gulp-rename": "^1.3.0",
|
||||
"gulp-uglify": "^3.0.0",
|
||||
"gulp-useref": "^3.1.3",
|
||||
"gulp-zip": "^4.1.0",
|
||||
"husky": "^0.14.3",
|
||||
"identity-obj-proxy": "^3.0.0",
|
||||
"if-env": "^1.0.0",
|
||||
|
18
yarn.lock
18
yarn.lock
@ -4463,6 +4463,16 @@ gulp-util@^3.0.0, gulp-util@^3.0.1:
|
||||
through2 "^2.0.0"
|
||||
vinyl "^0.5.0"
|
||||
|
||||
gulp-zip@^4.1.0:
|
||||
version "4.1.0"
|
||||
resolved "https://registry.yarnpkg.com/gulp-zip/-/gulp-zip-4.1.0.tgz#dab178bd99afa190923f1eb78abaf0db47817704"
|
||||
dependencies:
|
||||
get-stream "^3.0.0"
|
||||
plugin-error "^0.1.2"
|
||||
through2 "^2.0.1"
|
||||
vinyl "^2.1.0"
|
||||
yazl "^2.1.0"
|
||||
|
||||
gulp@^3.9.1:
|
||||
version "3.9.1"
|
||||
resolved "https://registry.yarnpkg.com/gulp/-/gulp-3.9.1.tgz#571ce45928dd40af6514fc4011866016c13845b4"
|
||||
@ -9692,7 +9702,7 @@ vinyl@^1.0.0:
|
||||
clone-stats "^0.0.1"
|
||||
replace-ext "0.0.1"
|
||||
|
||||
vinyl@^2.0.0:
|
||||
vinyl@^2.0.0, vinyl@^2.1.0:
|
||||
version "2.1.0"
|
||||
resolved "https://registry.yarnpkg.com/vinyl/-/vinyl-2.1.0.tgz#021f9c2cf951d6b939943c89eb5ee5add4fd924c"
|
||||
dependencies:
|
||||
@ -10082,3 +10092,9 @@ yauzl@^2.2.1:
|
||||
dependencies:
|
||||
buffer-crc32 "~0.2.3"
|
||||
fd-slicer "~1.1.0"
|
||||
|
||||
yazl@^2.1.0:
|
||||
version "2.4.3"
|
||||
resolved "https://registry.yarnpkg.com/yazl/-/yazl-2.4.3.tgz#ec26e5cc87d5601b9df8432dbdd3cd2e5173a071"
|
||||
dependencies:
|
||||
buffer-crc32 "~0.2.3"
|
||||
|
Reference in New Issue
Block a user