-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
executable file
·99 lines (88 loc) · 2.47 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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
var gulp = require("gulp");
var ejs = require("gulp-ejs"),
sass = require("gulp-sass"),
pleeease = require("gulp-pleeease"),
browser = require("browser-sync"),
minifyCss = require('gulp-minify-css'),
typescript = require('gulp-tsc'), // TypeScript Compiler
plumber = require('gulp-plumber') // 自動復帰
var DEV = "source",
PUBLIC = "build";
//ejse
gulp.task("ejs", function() {
gulp.src(
[DEV + "/ejs/**/*.ejs",'!' + DEV + "/ejs/**/_*.ejs"]
)
.pipe(ejs(null,{"ext": ".html"}))
.pipe(gulp.dest(PUBLIC))
.pipe(browser.reload({stream:true}));
});
//style
gulp.task("style", function() {
gulp.src(DEV + "/sass/**/*.scss")
.pipe(sass({
style:"nested",
includePaths:DEV+"/sass/common",
compass : true,
"sourcemap=none": true,
minifier: false,
}))
.pipe(pleeease({
fallbacks: {
autoprefixer: ["last 2 version", "ie 9"],
},
minifier: true//圧縮を有効
}))
.pipe(gulp.dest(PUBLIC + "/css"))
.pipe(browser.reload({stream:true}));
});
//copy
gulp.task("js", function() {
return gulp.src(DEV + "/js/**/*.js")
.pipe(gulp.dest(PUBLIC + "/js"))
.pipe(browser.reload({stream:true}));
});
//lib
gulp.task("lib", function() {
return gulp.src(DEV + "/lib/**/*.js")
.pipe(gulp.dest(PUBLIC + "/lib"));
});
//lib
gulp.task("images", function() {
return gulp.src(DEV + "/images/**/*")
.pipe(gulp.dest(PUBLIC + "/images"));
});
//browser sync
gulp.task("server", function() {
browser({
server: {
baseDir: PUBLIC
},
port: 5000
,ui:{port:5001}
});
});
//Just reload
gulp.task("reload", function() { browser.reload() });
//TypeScript
gulp.task('typescript', function(){
gulp.src([DEV +'/ts/main.ts'])
.pipe(plumber())
.pipe(typescript({
sourceMap: true,
sourceRoot: '/ts/',
declaration: true ,
removeComments: true,
out: "main.js"}))
.pipe(gulp.dest((PUBLIC + "/js")))
});
//watch
gulp.task("default",["ejs","style","js","lib","images","server"], function() {
gulp.watch(DEV + "/ejs/**/*.ejs",["ejs"]);
gulp.watch(DEV + "/sass/**/*.scss",["style"]);
gulp.watch(DEV + "/js/**/*.js",["js"]);
gulp.watch(PUBLIC + "/js/**/*.js",["reload"]);
gulp.watch(DEV + "/ts/**/*.ts",["typescript"]);
gulp.watch(DEV + "/lib/**/*.js",["lib"]);
gulp.watch(DEV + "/images/**/*",["images"]);
});