-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgulpfile.js
64 lines (57 loc) · 1.71 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
/*jshint esversion: 6 */
const autoprefixer = require("autoprefixer");
const babel = require("gulp-babel");
const cachebust = require('gulp-cache-bust');
const concat = require("gulp-concat");
const cssnano = require("cssnano");
const gulp = require("gulp");
const pug = require("gulp-pug");
const postcss = require('gulp-postcss');
const pxtorem = require('postcss-pxtorem');
const rucksack = require('rucksack-css');
const sourcemaps = require('gulp-sourcemaps');
const stylus = require("gulp-stylus");
const surge = require("gulp-surge");
const webserver = require("gulp-webserver");
gulp.task('webserver', function () {
return gulp.src("dist")
.pipe(webserver({
livereload: true,
open: true
}));
});
gulp.task('html', function() {
return gulp.src('views/pages/partials/**/*.pug')
.pipe(pug())
.pipe(cachebust({
type: 'timestamp'
}))
.pipe(gulp.dest('public/partials'));
});
gulp.task('css', function() {
return gulp.src('stylesheets/*.styl')
.pipe(sourcemaps.init())
.pipe(stylus())
.pipe(postcss([autoprefixer, rucksack, pxtorem, cssnano]))
.pipe(sourcemaps.write('.'))
.pipe(gulp.dest('public/css'));
});
gulp.task('js', function() {
return gulp.src('src/js/**/*.js')
.pipe(babel({
comments: false,
presets: ['env'],
minified: true
}))
.pipe(concat('scripts.js'))
.pipe(gulp.dest('public/js'));
});
gulp.task('deploy', function() {
return surge({
project: './dist/',
domain: 'projectbeta.surge.sh'
});
});
gulp.task('default', ['html', 'css', 'js'], function () {
gulp.watch(['stylesheets/**/*.styl', 'views/**/*.pug', 'src/js/**/*.js'], ['html', 'css', 'js']);
});