-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathgulpfile.js
90 lines (79 loc) · 2.83 KB
/
gulpfile.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
'use strict';
var gulp = require('gulp');
// var gutil = require('gulp-util');
var derequire = require('gulp-derequire');
var livereload = require('gulp-livereload');
var plumber = require('gulp-plumber');
var sourcemaps = require('gulp-sourcemaps');
var paths = {
styles: 'src/glslEditor/src/css/**/*.css',
scripts: 'src/glslEditor/src/js/**/*.js'
};
// Build stylesheets
gulp.task('css', function () {
var postcss = require('gulp-postcss');
var autoprefixer = require('autoprefixer');
var cssimport = require('postcss-import');
var nested = require('postcss-nested');
var customProperties = require('postcss-custom-properties');
var colorHexAlpha = require('postcss-color-hex-alpha');
var csswring = require('csswring');
var reporter = require('postcss-reporter');
var plugins = [
cssimport,
nested,
customProperties(),
colorHexAlpha(),
autoprefixer({ browsers: ['last 2 versions', 'IE >= 11'] }),
// preserveHacks is true because NOT preserving them doesn't mean
// delete the hack, it means turn it into real CSS. Which is not
// what we want!
csswring({ removeAllComments: true, preserveHacks: true }),
reporter()
];
return gulp.src('./src/glslEditor/src/css/glslEditor.css')
.pipe(plumber())
.pipe(sourcemaps.init())
.pipe(postcss(plugins))
.pipe(sourcemaps.write('.'))
.pipe(gulp.dest('./src/www/build'))
.pipe(livereload());
});
// Build Javascripts
gulp.task('js', function () {
var browserify = require('browserify');
// not working on Windows var shim = require('browserify-shim');
var babelify = require('babelify');
var source = require('vinyl-source-stream');
var buffer = require('vinyl-buffer');
// var uglify = require('gulp-uglify');
var bundle = browserify({
entries: 'src/glslEditor/src/js/GlslEditor.js',
standalone: 'GlslEditor',
debug: true,
transform: [
babelify.configure({ optional: ['runtime'] })// not working on Windows ,shim
]
});
return bundle.bundle()
.pipe(plumber())
.pipe(source('glslEditor.js'))
.pipe(derequire())
.pipe(buffer())
// .pipe(sourcemaps.init({ loadMaps: true }))
// Add transformation tasks to the pipeline here.
// .pipe(uglify())
// .on('error', gutil.log)
// .pipe(sourcemaps.write('.'))
.pipe(gulp.dest('./src/www/build'));
});
// Rerun the task when a file changes
gulp.task('watch', function () {
livereload.listen();
gulp.watch(paths.styles, ['css']);
gulp.watch(paths.scripts, ['js']);
});
// Build files, do not watch
gulp.task('build', ['css', 'js']);
// The default task (called when you run `gulp` from cli)
gulp.task('default', ['css', 'js', 'watch']);