-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
52 lines (47 loc) · 1.32 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
var gulp = require('gulp');
var plugins = require('gulp-load-plugins')();
var browserSync = require('browser-sync').create();
var path = require('path');
var PATHS = {
app: path.join(__dirname, 'assets/'),
js: path.join(__dirname, 'assets/js/'),
sass: path.join(__dirname, 'assets/sass/'),
dist: path.join(__dirname, 'assets/dist/')
};
gulp.task('js', function() {
return gulp.src(PATHS.js + '*.js')
.pipe(plugins.browserify({
transform: 'babelify',
insertGlobals : true,
debug : !gulp.env.production
}))
.pipe(plugins.rename({
suffix: '.min'
}))
.pipe(plugins.uglify())
.pipe(gulp.dest(PATHS.dist + 'js/'))
.pipe(browserSync.stream());
});
gulp.task('sass', function() {
return gulp.src(PATHS.sass + '*.scss')
.pipe(plugins.sass().on('error', plugins.sass.logError))
.pipe(plugins.rename({
suffix: '.min'
}))
.pipe(plugins.cleanCss({
compatibility: 'ie8'
}))
.pipe(gulp.dest(PATHS.dist + 'css/'))
.pipe(browserSync.stream());
});
gulp.task('server', ['js', 'sass'], function() {
browserSync.init({
server: {
baseDir: './assets'
}
});
gulp.watch(PATHS.app + '*.html', browserSync.reload);
gulp.watch(PATHS.js + '**/*.js', ['js']);
gulp.watch(PATHS.sass + '**/*.scss', ['sass']);
});
gulp.task('default', ['server']);