mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-16 14:17:22 +01:00
Move browserify task to gulp
This commit is contained in:
16
Gruntfile.js
16
Gruntfile.js
@@ -51,17 +51,6 @@ module.exports = function(grunt) {
|
||||
}
|
||||
},
|
||||
|
||||
browserify: {
|
||||
dist: {
|
||||
src: ["common/index.js"],
|
||||
dest: "common/dist/scripts/habitrpg-shared.js"
|
||||
},
|
||||
options: {
|
||||
transform: ['coffeeify']
|
||||
//debug: true Huge data uri source map (400kb!)
|
||||
}
|
||||
},
|
||||
|
||||
copy: {
|
||||
build: {
|
||||
files: [
|
||||
@@ -134,8 +123,8 @@ module.exports = function(grunt) {
|
||||
});
|
||||
|
||||
// Register tasks.
|
||||
grunt.registerTask('build:prod', ['loadManifestFiles', 'clean:build', 'browserify', 'uglify', 'stylus', 'cssmin', 'copy:build', 'hashres']);
|
||||
grunt.registerTask('build:dev', ['browserify', 'cssmin', 'stylus']);
|
||||
grunt.registerTask('build:prod', ['loadManifestFiles', 'clean:build', 'uglify', 'stylus', 'cssmin', 'copy:build', 'hashres']);
|
||||
grunt.registerTask('build:dev', ['cssmin', 'stylus']);
|
||||
grunt.registerTask('build:test', ['test:prepare:translations', 'build:dev']);
|
||||
|
||||
grunt.registerTask('test:prepare:translations', function() {
|
||||
@@ -148,7 +137,6 @@ module.exports = function(grunt) {
|
||||
});
|
||||
|
||||
// Load tasks
|
||||
grunt.loadNpmTasks('grunt-browserify');
|
||||
grunt.loadNpmTasks('grunt-contrib-uglify');
|
||||
grunt.loadNpmTasks('grunt-contrib-clean');
|
||||
grunt.loadNpmTasks('grunt-contrib-stylus');
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
"async": "~0.9.0",
|
||||
"aws-sdk": "^2.0.25",
|
||||
"babel": "^5.5.4",
|
||||
"gulp-babel": "^5.2.1",
|
||||
"babelify": "^7.2.0",
|
||||
"bower": "~1.3.12",
|
||||
"browserify": "~12.0.1",
|
||||
"coffee-script": "1.6.x",
|
||||
@@ -23,7 +23,6 @@
|
||||
"firebase-token-generator": "^2.0.0",
|
||||
"glob": "^4.3.5",
|
||||
"grunt": "~0.4.1",
|
||||
"grunt-browserify": "^3.3.0",
|
||||
"grunt-cli": "~0.1.9",
|
||||
"grunt-contrib-clean": "~0.6.0",
|
||||
"grunt-contrib-copy": "~0.6.0",
|
||||
@@ -38,6 +37,8 @@
|
||||
"gulp-grunt": "^0.5.2",
|
||||
"gulp-imagemin": "^2.3.0",
|
||||
"gulp-nodemon": "^2.0.4",
|
||||
"gulp-sourcemaps": "^1.6.0",
|
||||
"gulp-uglify": "^1.4.2",
|
||||
"gulp.spritesmith": "^4.1.0",
|
||||
"icalendar": "lefnire/node-icalendar#e06da0e55901f0ba940dfadc42c158ed0b1fead9",
|
||||
"image-size": "~0.3.2",
|
||||
@@ -75,6 +76,8 @@
|
||||
"swagger-node-express": "lefnire/swagger-node-express#habitrpg",
|
||||
"universal-analytics": "~0.3.2",
|
||||
"validator": "~3.19.0",
|
||||
"vinyl-buffer": "^1.0.0",
|
||||
"vinyl-source-stream": "^1.1.0",
|
||||
"winston": "~0.8.0",
|
||||
"winston-mail": "~0.2.9",
|
||||
"winston-newrelic": "~0.1.4"
|
||||
|
||||
@@ -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