-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
64 lines (53 loc) · 1.63 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
const del = require('del');
const gulp = require('gulp');
const gulpLoadPlugins = require('gulp-load-plugins');
const moduleImporter = require('sass-module-importer');
const browserSync = require('browser-sync');
const $ = gulpLoadPlugins();
const reload = browserSync.reload;
const dir = {
src: './source',
dest: './.tmp'
}
gulp.task('clean', () => del([`${dir.dest}/*`], { dot: true }));
gulp.task('styles', () => {
const AUTOPREFIXER_BROWSERS = [
'ie >= 10',
'ie_mob >= 10',
'ff >= 30',
'chrome >= 34',
'safari >= 7',
'opera >= 23',
'ios >= 7',
'android >= 4.4',
'bb >= 10',
];
return gulp.src(`${dir.src}/stylesheets/**/*.scss`)
.pipe($.sourcemaps.init())
.pipe($.sass({ importer: moduleImporter() }).on('error', $.sass.logError))
.pipe($.autoprefixer(AUTOPREFIXER_BROWSERS))
.pipe($.sourcemaps.write('./maps'))
.pipe(gulp.dest(`${dir.dest}/stylesheets`));
});
gulp.task('scripts', () =>
gulp.src(`${dir.src}/javascripts/**/*.js`)
.pipe($.plumber())
// .pipe($.sourcemaps.init())
.pipe($.babel({ presets: ['es2015'] }))
// .pipe($.sourcemaps.write())
.pipe(gulp.dest(`${dir.dest}/javascripts`)));
gulp.task('serve', ['styles', 'scripts'], () => {
browserSync({
notify: false,
logPrefix: 'WSK',
proxy: 'localhost:4567',
port: 3000,
reloadDelay : 1000,
files: [`${dir.src}/**/*.{erb,html,haml}`]
});
gulp.watch([`${dir.src}/stylesheets/**/*.scss`], ['styles']);
gulp.watch([`${dir.src}/javascripts/**/*.js`], ['scripts', reload]);
});
gulp.task('default', ['dev']);
gulp.task('dev', ['serve']);
gulp.task('build', ['styles', 'scripts']);