[881] | 1 | var gulp = require('gulp'); |
---|
| 2 | var browserify = require('browserify'); |
---|
| 3 | var eslint = require('gulp-eslint'); |
---|
| 4 | var babelify = require('babelify'); |
---|
| 5 | var source = require('vinyl-source-stream'); |
---|
| 6 | var buffer = require('vinyl-buffer'); |
---|
| 7 | var browserSync = require('browser-sync').create(); |
---|
| 8 | var sourcemaps = require('gulp-sourcemaps'); |
---|
| 9 | var jsdoc = require('gulp-jsdoc3'); |
---|
| 10 | |
---|
| 11 | gulp.task('eslint', function() { |
---|
| 12 | return gulp.src(['src/**/*.jsx','src/**/*.js', 'src/*.jsx']) |
---|
| 13 | .pipe(eslint()) |
---|
| 14 | .pipe(eslint.format()) |
---|
| 15 | .pipe(eslint.failOnError()); |
---|
| 16 | }); |
---|
| 17 | |
---|
| 18 | gulp.task('build', function () { |
---|
| 19 | return browserify({entries: './src/app.jsx', extensions: ['.jsx'], debug: true}) |
---|
| 20 | .ignore('./sdk-core/frams_sdk.js', './external/physijs/*') |
---|
| 21 | .transform(babelify, {presets: ['es2015', 'react']}) |
---|
| 22 | .bundle() |
---|
| 23 | .pipe(source('bundle.js')) |
---|
| 24 | .pipe(buffer()) |
---|
| 25 | .pipe(sourcemaps.init({loadMaps: true})) |
---|
| 26 | .pipe(sourcemaps.write('.', { |
---|
| 27 | includeContent: true, |
---|
| 28 | sourceRoot: '.' |
---|
| 29 | })) |
---|
| 30 | .pipe(gulp.dest('dist')); |
---|
| 31 | }); |
---|
| 32 | |
---|
| 33 | gulp.task('watch', ['eslint', 'build'], function () { |
---|
| 34 | gulp.watch(['src/**/*.jsx','src/**/*.js'], ['build']); |
---|
| 35 | }); |
---|
| 36 | |
---|
| 37 | gulp.task('browser-sync', function() { |
---|
| 38 | browserSync.init({ |
---|
| 39 | server: { |
---|
| 40 | baseDir: "./" |
---|
| 41 | } |
---|
| 42 | }); |
---|
| 43 | gulp.watch("dist/*").on('change',browserSync.reload); |
---|
| 44 | }); |
---|
| 45 | |
---|
| 46 | gulp.task('doc', function(cb) { |
---|
| 47 | gulp.src(['DOCUMENTATION.md', './src/**/*.jsx', './src/**/*.js'], {read: false}) |
---|
| 48 | .pipe(jsdoc(cb)); |
---|
| 49 | }); |
---|
| 50 | |
---|
| 51 | gulp.task('default', ['eslint', 'build']); |
---|