-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
76 lines (66 loc) · 1.61 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
76
let gulp = require("gulp");
let sass = require("gulp-sass");
let postcss = require("gulp-postcss");
let autoprefixer = require("autoprefixer");
let cssnano = require("cssnano");
let sourcemaps = require("gulp-sourcemaps");
var ts = require('gulp-typescript');
let paths = {
css: {
// By using styles/**/*.sass we're telling gulp to check all folders for any sass file
src: "src/scss/**/*.scss",
// Compiled files will end up in whichever folder it's found in (partials are not compiled)
dest: "css"
},
js: {
src: "src/js/**/*.ts",
dest: "js"
}
};
/***
* TYPESCIRPT
*/
function scripts() {
return(
gulp
.src(paths.js.src)
.pipe(ts({
noImplicitAny: true,
outFile: 'web-bundle.js'
}))
.pipe(gulp.dest(paths.js.dest)
));
}
/***
* CSS
*/
function style() {
return (
gulp
.src(paths.css.src)
// Initialize sourcemaps before compilation starts
.pipe(sourcemaps.init())
.pipe(sass())
.on("error", sass.logError)
// Use postcss with autoprefixer and compress the compiled file using cssnano
.pipe(postcss([autoprefixer(), cssnano()]))
// Now add/write the sourcemaps
.pipe(sourcemaps.write())
.pipe(gulp.dest(paths.css.dest))
);
}
/***
* FILEWATCH
*/
function watch(){
style();
scripts();
gulp.watch(paths.css.src, style);
gulp.watch(paths.js.src, scripts);
}
/***
* RUN
*/
exports.style = style;
exports.watch = watch;
exports.scripts = scripts;