-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathgulpfile.js
88 lines (78 loc) · 2.49 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
/* jshint node:true */
var gulp = require('gulp'),
gutil = require('gulp-util'),
gulpLoadPlugins = require('gulp-load-plugins'),
minifyCss = require('gulp-minify-css'),
plugins = gulpLoadPlugins(),
config = {},
pathTo;
try {
config = require('./config/ouija.json');
} catch(e) {
console.log('ouija.json not found in config/');
}
pathTo = {
assets: '../../themes/' + config.theme + '/assets/',
styles: 'app/styles/**.scss',
entry: 'app/index.js',
dist: 'dist/',
get distScripts () { return this.assets + 'js/' },
get distStyles () { return this.assets + 'css/' },
sourceFiles: './app/**/*.js',
watch: ['**.js', 'styles/**.scss'].map(function (path) {
return 'app/' + path;
})
};
gulp.task('build', function () {
gulp.src(pathTo.styles)
.pipe(plugins.sass({
includePaths: require('node-bourbon').includePaths
}))
.pipe(plugins.rename('ouija.css'))
.pipe(gulp.dest(pathTo.dist))
.pipe(minifyCss({ keepBreaks:true }))
.pipe(plugins.rename('ouija.min.css'))
.pipe(gulp.dest(pathTo.dist));
gulp.src(pathTo.entry)
.pipe(plugins.browserify({
insertGlobals : false,
debug: false
}))
.pipe(plugins.rename('ouija.js'))
.pipe(gulp.dest(pathTo.dist))
.pipe(plugins.uglify({ mangle: false }))
.pipe(plugins.rename('ouija.min.js'))
.pipe(gulp.dest(pathTo.dist));
});
gulp.task('develop', ['sass'], function () {
gulp.src(pathTo.entry)
.pipe(plugins.browserify({
insertGlobals : false,
debug: !process.env.NODE_ENV
}))
.pipe(plugins.rename('ouija.js'))
.pipe(gulp.dest(pathTo.distScripts));
});
gulp.task('sass', function () {
gulp.src(pathTo.styles)
.pipe(plugins.sass({
errLogToConsole: true,
sourceComments: 'none',
includePaths: require('node-bourbon').includePaths
}))
.pipe(plugins.rename('ouija.css'))
.pipe(gulp.dest(pathTo.distStyles));
});
gulp.task('lint', function () {
return gulp.src(pathTo.sourceFiles)
.pipe(plugins.jshint())
.pipe(plugins.jshint.reporter('jshint-stylish'))
.pipe(plugins.jshint.reporter('fail'));
});
gulp.task('test', ['lint']);
// Run the develop task when a file change changes
gulp.task('default', ['develop'], function () {
gulp.watch(pathTo.watch).on('change', function () {
gulp.start('develop');
});
});