forked from TyIsI/deletron3030
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
70 lines (64 loc) · 1.93 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
'use strict';
var gulp = require('gulp'),
browserify = require('browserify'),
source = require('vinyl-source-stream'),
buffer = require('vinyl-buffer'),
babelify = require('babelify'),
browserSync = require('browser-sync'),
reload = browserSync.reload,
scss = require("postcss-scss"),
$ = require('gulp-load-plugins')();
const lint = [
require('stylelint')(),
require('postcss-reporter')({ clearMessages: true, throwError: true })
];
const postcss = [
require('css-mqpacker')(),
require('postcss-discard-duplicates')(),
require('postcss-unique-selectors')(),
require('pixrem')(),
require('lost')(),
require('autoprefixer')({ browsers: ['last 5 versions', '> 10%', 'IE 9']}),
require('cssnano')(),
require('postcss-reporter')({ clearMessages: true})
];
gulp.task('styles', () => {
return gulp.src('./assets/styles/**/*.scss')
.pipe($.plumber({
errorHandler: $.notify.onError({
title: "Style Error",
message: "<%= error.message %>"
})
}))
.pipe($.sourcemaps.init())
.pipe($.postcss(lint, { syntax: scss }))
.pipe($.sass().on('error', $.sass.logError))
.pipe($.postcss(postcss))
.pipe($.sourcemaps.write('.'))
.pipe(gulp.dest('./public/styles'))
.pipe(reload({stream:true}));
});
gulp.task('scripts', () => {
browserify('./assets/scripts/index.js')
.transform( babelify, { presets: ['es2015', 'react', 'stage-1'] })
.bundle().on('error', $.notify.onError({
title: "JSX Error",
message: "<%= error.message %>"
}))
.pipe(source('app.min.js'))
.pipe(buffer())
.pipe($.sourcemaps.init({loadMaps: true}))
.pipe($.uglify())
.pipe($.sourcemaps.write('.'))
.pipe(gulp.dest('./public/scripts'))
.pipe(reload({stream:true}));
});
gulp.task('bs', () => {
browserSync({
proxy: "http://localhost:3000"
})
});
gulp.task('default', ['styles', 'scripts', 'bs'], () => {
gulp.watch('./assets/scripts/**/*.js',['scripts']);
gulp.watch('./assets/styles/**/*.scss', ['styles']);
});