mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-15 21:57:22 +01:00
Move browserify task to gulp
This commit is contained in:
@@ -1,16 +1,31 @@
|
||||
import gulp from 'gulp';
|
||||
import babel from 'gulp-babel';
|
||||
import browserify from 'browserify';
|
||||
import source from 'vinyl-source-stream';
|
||||
import buffer from 'vinyl-buffer';
|
||||
import uglify from 'gulp-uglify';
|
||||
import sourcemaps from 'gulp-sourcemaps';
|
||||
import babel from 'babelify';
|
||||
|
||||
const ES2015_SOURCE = 'common/script/src/**/*.js';
|
||||
const ES2015_DIST = 'common/dist/scripts/';
|
||||
gulp.task('browserify', function () {
|
||||
let bundler = browserify({
|
||||
entries: './common/index.js',
|
||||
debug: true,
|
||||
transform: [[babel, { compact: false }]]
|
||||
});
|
||||
|
||||
gulp.task('babel:common', () => {
|
||||
return gulp.src(ES2015_SOURCE)
|
||||
.pipe(babel())
|
||||
.pipe(gulp.dest(ES2015_DIST));
|
||||
return bundler.bundle()
|
||||
.pipe(source('habitrpg-shared.js'))
|
||||
.pipe(buffer())
|
||||
.pipe(sourcemaps.init({loadMaps: true}))
|
||||
.pipe(uglify())
|
||||
.on('error', function (err) {
|
||||
console.error(err);
|
||||
this.emit('end');
|
||||
})
|
||||
.pipe(sourcemaps.write('./'))
|
||||
.pipe(gulp.dest('./common/dist/scripts/'));
|
||||
});
|
||||
|
||||
gulp.task('babel:common:watch', () => {
|
||||
gulp.watch([ES2015_SOURCE], ['babel:common']);
|
||||
gulp.task('browserify:watch', () => {
|
||||
gulp.watch('./common/script/**/*.js', ['browserify']);
|
||||
});
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ gulp.task('build', () => {
|
||||
}
|
||||
});
|
||||
|
||||
gulp.task('build:dev', ['babel:common', 'prepare:staticNewStuff'], (done) => {
|
||||
gulp.task('build:dev', ['browserify', 'prepare:staticNewStuff'], (done) => {
|
||||
gulp.start('grunt-build:dev', done);
|
||||
});
|
||||
|
||||
@@ -17,6 +17,6 @@ gulp.task('build:dev:watch', ['build:dev'], () => {
|
||||
gulp.watch(['website/public/**/*.styl', 'common/script/*']);
|
||||
});
|
||||
|
||||
gulp.task('build:prod', ['babel:common', 'prepare:staticNewStuff'], (done) => {
|
||||
gulp.task('build:prod', ['browserify', 'prepare:staticNewStuff'], (done) => {
|
||||
gulp.start('grunt-build:prod', done);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user