#35 Creating dist for each browser including zipped version
This commit is contained in:
parent
a16c6703b7
commit
24e1f7c710
112
gulpfile.js
112
gulpfile.js
|
@ -7,6 +7,7 @@ const browserify = require('browserify');
|
||||||
const babelify = require('babelify');
|
const babelify = require('babelify');
|
||||||
const source = require('vinyl-source-stream');
|
const source = require('vinyl-source-stream');
|
||||||
const buffer = require('vinyl-buffer');
|
const buffer = require('vinyl-buffer');
|
||||||
|
const merge = require('merge-stream');
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
|
|
||||||
const $ = gulpLoadPlugins()
|
const $ = gulpLoadPlugins()
|
||||||
|
@ -33,17 +34,30 @@ const tmp = {
|
||||||
styles: '.tmp/stylesheets',
|
styles: '.tmp/stylesheets',
|
||||||
scripts: '.tmp/javascript',
|
scripts: '.tmp/javascript',
|
||||||
images: '.tmp/images',
|
images: '.tmp/images',
|
||||||
vendor: '.tmp/libs',
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Dist path
|
// Dist path
|
||||||
const dist = {
|
const dist = {
|
||||||
root: 'dist',
|
root: 'dist',
|
||||||
manifests: 'dist/manifests',
|
chrome: {
|
||||||
styles: 'dist/stylesheets',
|
root: 'dist/chrome',
|
||||||
scripts: 'dist/javascript',
|
styles: 'dist/chrome/stylesheets',
|
||||||
images: 'dist/images',
|
scripts: 'dist/chrome/javascript',
|
||||||
vendor: 'dist/libs',
|
images: 'dist/chrome/images',
|
||||||
|
},
|
||||||
|
firefox: {
|
||||||
|
root: 'dist/firefox',
|
||||||
|
styles: 'dist/firefox/stylesheets',
|
||||||
|
scripts: 'dist/firefox/javascript',
|
||||||
|
images: 'dist/firefox/images',
|
||||||
|
},
|
||||||
|
opera: {
|
||||||
|
root: 'dist/opera',
|
||||||
|
styles: 'dist/opera/stylesheets',
|
||||||
|
scripts: 'dist/opera/javascript',
|
||||||
|
images: 'dist/opera/images',
|
||||||
|
},
|
||||||
|
zip: 'dist/zips',
|
||||||
}
|
}
|
||||||
|
|
||||||
// Build mode
|
// Build mode
|
||||||
|
@ -169,24 +183,82 @@ gulp.task('build', gulp.series('clean:build', 'manifests', 'images', 'scripts',
|
||||||
DIST CLEAN ALL
|
DIST CLEAN ALL
|
||||||
============================================================================ */
|
============================================================================ */
|
||||||
|
|
||||||
gulp.task('dist:copy', (done) => {
|
gulp.task('dist:chrome', (done) => {
|
||||||
// copy vendor
|
return merge(
|
||||||
gulp.src(`${tmp.vendor}/**/*`)
|
// copy images
|
||||||
.pipe(gulp.dest(dist.vendor))
|
gulp.src(`${tmp.images}/**/*`)
|
||||||
|
.pipe(gulp.dest(dist.chrome.images)),
|
||||||
|
|
||||||
// copy images
|
// copy scripts
|
||||||
gulp.src(`${tmp.images}/**/*`)
|
gulp.src(`${tmp.scripts}/**/*.{min.js,min.js.gz}`)
|
||||||
.pipe(gulp.dest(dist.images))
|
.pipe(gulp.dest(dist.chrome.scripts)),
|
||||||
|
|
||||||
// copy scripts
|
// copy styles
|
||||||
gulp.src(`${tmp.scripts}/**/*.{min.js,min.js.gz}`)
|
gulp.src(`${tmp.styles}/*.{min.css,min.css.gz}`)
|
||||||
.pipe(gulp.dest(dist.scripts))
|
.pipe(gulp.dest(dist.chrome.styles)),
|
||||||
|
|
||||||
// copy styles
|
gulp.src(`${tmp.manifests}/chrome*`)
|
||||||
gulp.src(`${tmp.styles}/*.{min.css,min.css.gz}`)
|
.pipe($.rename('manifest.json'))
|
||||||
.pipe(gulp.dest(dist.styles))
|
.pipe(gulp.dest(dist.chrome.root))
|
||||||
|
);
|
||||||
|
})
|
||||||
|
|
||||||
|
gulp.task('dist:firefox', (done) => {
|
||||||
|
return merge(
|
||||||
|
// copy images
|
||||||
|
gulp.src(`${tmp.images}/**/*`)
|
||||||
|
.pipe(gulp.dest(dist.firefox.images)),
|
||||||
|
|
||||||
|
// copy scripts
|
||||||
|
gulp.src(`${tmp.scripts}/**/*.{min.js,min.js.gz}`)
|
||||||
|
.pipe(gulp.dest(dist.firefox.scripts)),
|
||||||
|
|
||||||
|
// copy styles
|
||||||
|
gulp.src(`${tmp.styles}/*.{min.css,min.css.gz}`)
|
||||||
|
.pipe(gulp.dest(dist.firefox.styles)),
|
||||||
|
|
||||||
|
gulp.src(`${tmp.manifests}/firefox*`)
|
||||||
|
.pipe($.rename('manifest.json'))
|
||||||
|
.pipe(gulp.dest(dist.firefox.root))
|
||||||
|
);
|
||||||
|
})
|
||||||
|
|
||||||
|
gulp.task('dist:opera', (done) => {
|
||||||
|
return merge(
|
||||||
|
// copy images
|
||||||
|
gulp.src(`${tmp.images}/**/*`)
|
||||||
|
.pipe(gulp.dest(dist.opera.images)),
|
||||||
|
|
||||||
|
// copy scripts
|
||||||
|
gulp.src(`${tmp.scripts}/**/*.{min.js,min.js.gz}`)
|
||||||
|
.pipe(gulp.dest(dist.opera.scripts)),
|
||||||
|
|
||||||
|
// copy styles
|
||||||
|
gulp.src(`${tmp.styles}/*.{min.css,min.css.gz}`)
|
||||||
|
.pipe(gulp.dest(dist.opera.styles)),
|
||||||
|
|
||||||
|
gulp.src(`${tmp.manifests}/opera*`)
|
||||||
|
.pipe($.rename('manifest.json'))
|
||||||
|
.pipe(gulp.dest(dist.opera.root))
|
||||||
|
);
|
||||||
|
})
|
||||||
|
|
||||||
|
gulp.task('dist:copy', gulp.series('dist:chrome', 'dist:firefox', 'dist:opera'));
|
||||||
|
|
||||||
|
gulp.task('dist:zip', (done) => {
|
||||||
|
gulp.src(`${dist.chrome.root}/**/*`)
|
||||||
|
.pipe($.zip('chrome.zip'))
|
||||||
|
.pipe(gulp.dest(dist.root));
|
||||||
|
|
||||||
|
gulp.src(`${dist.firefox.root}/**/*`)
|
||||||
|
.pipe($.zip('firefox.zip'))
|
||||||
|
.pipe(gulp.dest(dist.root));
|
||||||
|
|
||||||
|
gulp.src(`${dist.opera.root}/**/*`)
|
||||||
|
.pipe($.zip('opera.zip'))
|
||||||
|
.pipe(gulp.dest(dist.root));
|
||||||
|
|
||||||
done();
|
done();
|
||||||
})
|
})
|
||||||
|
|
||||||
gulp.task('dist', gulp.series('clean', 'build', 'dist:copy'));
|
gulp.task('dist', gulp.series('clean', 'build', 'dist:copy', 'dist:zip'));
|
|
@ -34,6 +34,7 @@
|
||||||
"gulp-sourcemaps": "^2.6.5",
|
"gulp-sourcemaps": "^2.6.5",
|
||||||
"gulp-uglify-es": "^2.0.0",
|
"gulp-uglify-es": "^2.0.0",
|
||||||
"gulp-zip": "^5.0.2",
|
"gulp-zip": "^5.0.2",
|
||||||
|
"merge-stream": "^2.0.0",
|
||||||
"sass": "^1.26.10",
|
"sass": "^1.26.10",
|
||||||
"vinyl-buffer": "^1.0.1",
|
"vinyl-buffer": "^1.0.1",
|
||||||
"vinyl-source-stream": "^2.0.0"
|
"vinyl-source-stream": "^2.0.0"
|
||||||
|
|
Loading…
Reference in a new issue