forked from cmiller-wikia/wds-refapp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
82 lines (70 loc) · 2.18 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
var gulp = require('gulp');
// RUNNABLE COMMANDS
gulp.task('build', ['build:all']);
gulp.task('clean', ['clean:all']);
gulp.task('watch', ['watch:all']);
// IMPLEMENTATION
var
babelify = require('babelify'),
browserify = require('browserify'),
buffer = require('vinyl-buffer'),
del = require('del'),
hb = require('gulp-hb'),
fileInclude = require('gulp-file-include')
sassImporter = require('sassy-npm-importer')
rename = require('gulp-rename'),
scss = require('gulp-sass'),
sequence = require('run-sequence'),
source = require('vinyl-source-stream'),
sourcemaps = require('gulp-sourcemaps'),
uglify = require('gulp-uglify');
gulp.task('clean:all', function() {
return del('dist');
});
gulp.task('build:all', function() {
sequence('clean:all', ['templates:compile', 'statics:copy', 'build:css', 'build:js']);
})
gulp.task('templates:compile', function() {
return gulp
.src('./handlebars/templates/*.hbs')
.pipe(hb({
partials: './handlebars/partials/**/*.hbs',
helpers: './handlebars/helpers/**/*.js',
data: 'data/*.json'
}))
.pipe(fileInclude({prefix: '@@'}))
.pipe(rename({ extname: ".html"}))
.pipe(gulp.dest('./dist'));
});
gulp.task('statics:copy', function() {
return gulp.src('static/**')
.pipe(gulp.dest('./dist'));
});
gulp.task('build:css', function() {
return gulp.src('scss/styles.scss')
.pipe(scss({ importer: sassImporter() }))
.pipe(rename({ extname: ".css" }))
.pipe(gulp.dest('./dist/styles'));
});
gulp.task('build:js', function() {
var bundler = browserify({ entries: "js/wds.js", standalone: 'WDS', debug: true});
return bundler
.transform("babelify", { presets: ['es2015']} )
.bundle()
.pipe(source('wds.js'))
.pipe(buffer())
.pipe(sourcemaps.init({loadMaps: true}))
// Add transformation tasks to the pipeline here.
.pipe(uglify())
.pipe(sourcemaps.write('./'))
.pipe(gulp.dest('./dist/js'));
});
gulp.task('watch:all', ['build'], function() {
return gulp.watch([
"scss/**",
"static/**",
"handlebars/**",
"js/**",
"global.json"
],['build']);
});