Skip to content

Commit

Permalink
Update gulpfile
Browse files Browse the repository at this point in the history
  • Loading branch information
marcelklehr committed Apr 6, 2018
1 parent 9c05012 commit d9a5d84
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 2 deletions.
41 changes: 39 additions & 2 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,29 @@ var gulp = require('gulp')
var browserify = require('browserify')
var babelify = require('babelify')
var tap = require('gulp-tap')
var zip = require('gulp-zip')

const VERSION = require('./package.json').version
const paths = {
zip: [
'dist/*'
, 'icons/*'
, 'views/*'
, 'CHANGELOG.md'
, 'README.md'
, 'manifest.json'
, 'package.json'
, 'LICENSE.txt'
]
, views: './views/*.html'
, entries: 'src/entries/*.js'
, js: 'src/*'
}

gulp.task('default', ['html', 'js', '3rd-party'])

gulp.task('js', function () {
return gulp.src('src/entries/*.js', {read: false}) // no need of reading file because browserify does.
return gulp.src(paths.entries, {read: false}) // no need of reading file because browserify does.
// transform file objects using gulp-tap plugin
.pipe(tap(function (file) {
// replace file contents with browserify's bundle stream
Expand All @@ -28,7 +46,7 @@ gulp.task('js', function () {
})

gulp.task('html', function () {
return gulp.src('./views/*.html').pipe(gulp.dest('./dist/html/'))
return gulp.src(paths.views).pipe(gulp.dest('./dist/html/'))
})

gulp.task('3rd-party', ['polyfill', 'mocha'])
Expand All @@ -45,3 +63,22 @@ gulp.task('mochajs', function () {
gulp.task('mochacss', function () {
return gulp.src('./node_modules/mocha/mocha.css').pipe(gulp.dest('./dist/css/'))
})

gulp.task('release', ['zip', 'xpi'])

gulp.task('zip', ['default'], function () {
gulp.src(paths.zip)
.pipe(zip(`floccus-build-v${VERSION}.zip`))
.pipe(gulp.dest('../'))
})

gulp.task('xpi', ['default'], function () {
gulp.src(paths.zip)
.pipe(zip(`floccus-build-v${VERSION}.xpi`))
.pipe(gulp.dest('../'))
})

gulp.task('watch', function () {
gulp.watch(paths.js, ['js'])
gulp.watch(paths.views, ['html'])
})
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"chai-as-promised": "^7.1.1",
"gulp": "^3.9.1",
"gulp-tap": "^1.0.1",
"gulp-zip": "^4.1.0",
"mocha": "^5.0.4",
"through2": "^2.0.3"
},
Expand Down

0 comments on commit d9a5d84

Please sign in to comment.