-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
executable file
·72 lines (62 loc) · 2.1 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
var gulp = require('gulp');
var sass = require('gulp-sass');
var browserify = require('browserify');
var source = require('vinyl-source-stream');
var buffer = require('vinyl-buffer');
var jshint = require('gulp-jshint');
var browserSync = require('browser-sync').create();
var uglify = require('gulp-uglify');
var concat = require('gulp-concat');
var environments = require('gulp-environments');
var development = environments.development;
var production = environments.production;
/** load config file based on enviroment */
var configFile = production() ? "./src/env/prod.js" : "./src/env/dev.js";
gulp.task('lint', function() {
return gulp.src('./src/app/**/*.js')
.pipe(jshint())
.pipe(jshint.reporter('default'));
});
gulp.task('scripts', function(){
return gulp.src(['./src/assets/**/*.js',configFile])
.pipe(uglify())
.pipe(concat('vendor.min.js'))
.pipe(gulp.dest('./public/'));
});
gulp.task('browserify', function() {
// Grabs the app.js file
return browserify('./src/app/app.js')
// bundles it and creates a file called main.js
.bundle()
.pipe(source('main.js'))
.pipe(gulp.dest('./public/'));
})
gulp.task('copy', ['browserify','scss'], function() {
gulp.src(['./src/**/*.html','./src/**/*.css', './src/**/*.png'])
.pipe(gulp.dest('./public'))
.pipe(browserSync.stream())
});
gulp.task('scss', function() {
gulp.src('./src/assets/scss/*.scss')
.pipe(sass().on('error', sass.logError))
.pipe(gulp.dest('./src/assets/stylesheets/'));
});
gulp.task('build',['lint', 'scss', 'copy', 'scripts']);
gulp.task('browser-sync', ['build'], function() {
browserSync.init({
server: {
baseDir: "./public",
// The key is the url to match
// The value is which folder to serve (relative to your current working directory)
routes: {
"/bower_components": "bower_components",
"/node_modules": "node_modules"
}
},
browser:"firefox"
});
});
gulp.task('default', ['browser-sync'], function(){
gulp.watch("./src/**/*.*", ["build"]);
gulp.watch("./public/**/*.*").on('change', browserSync.reload);
})