-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
75 lines (65 loc) · 2.02 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
73
74
75
var gulp = require('gulp');
var concat = require('gulp-concat');
var less = require('gulp-less');
var sass = require('gulp-sass');
//var ignore=require("gulp-ignore");
var uglify = require("gulp-uglify");
var minifyCss = require('gulp-minify-css');
var webserver = require("gulp-webserver");
var htmlmin = require("gulp-htmlmin");
gulp.task('default', ['js', 'sass', "html"]);
// javascript task
gulp.task('js', function () {
if (process.env.NODE_ENV === 'production') {
var map = [
"app.js"
].map(function (script) {
return './assets/javascripts/' + script;
});
return gulp.src(map) // path to your files
.pipe(concat('app.js'))
.pipe(uglify())
.pipe(gulp.dest('./public/js/'));
} else {
var map = [
"app.js"
].map(function (script) {
return './assets/javascripts/' + script;
});
return gulp.src(map) // path to your files
.pipe(concat('app.js'))
.pipe(gulp.dest('./public/js/'));
}
});
// stylesheets task
gulp.task('sass', function () {
//main
var scss = [
"app.scss"
].map(function (script) {
return './assets/stylesheets/' + script;
});
return gulp.src(scss) // path to your file
.pipe(sass().on('error', sass.logError))
.pipe(minifyCss())
.pipe(gulp.dest('./public/style/'));
});
// compress html
gulp.task("html", function () {
return gulp.src("./assets/*.html")
.pipe(htmlmin({ collapseWhitespace: true }))
.pipe(gulp.dest("./public/"));
});
// gulp.task('watch', function () {
// gulp.watch(["./assets/javascripts/*.js"], ['map']);
// gulp.watch(["./assets/stylesheets/*.scss"], ['sass']);
// gulp.watch(["./assets/*.html"], ['html']);
// });
gulp.task('webserver', ['map', 'sass'], function () {
gulp.src("./public/").pipe(webserver({
liveload: true,
directoryListing: true,
open: "https://localhost:3313/index.html",
port: 3312
}));
});