-
Notifications
You must be signed in to change notification settings - Fork 46
/
Gulpfile.js
207 lines (183 loc) · 7.37 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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
var gulp = require('gulp');
var gutil = require("gulp-util");
var sass = require('gulp-sass');
var jshint = require('gulp-jshint');
var uglify = require('gulp-uglifyjs');
var rename = require('gulp-rename');
var replace = require("gulp-replace");
var concat = require('gulp-concat');
var notify = require('gulp-notify');
var header = require('gulp-header');
var minifycss = require('gulp-minify-css');
var autoprefixer = require('gulp-autoprefixer');
var clean = require("gulp-clean");
//var jsdoc = require("gulp-jsdoc");
//var jsdoc2md = require("gulp-jsdoc-to-markdown");
var fs = require("fs");
var pkg = require('./package.json');
var dateFormat = require('dateformatter').format;
var bowerPath = "./bower_components/";
pkg.name = "PlaneUI";
pkg.today = dateFormat;
var headerComment = ["/*!",
" * <%= pkg.name %> v<%= pkg.version %>",
" * @file <%= fileName(file) %> ",
" * @description <%= pkg.description %>",
" * @license MIT License",
" * @author <%= pkg.author %>",
" * {@link <%= pkg.homepage %>}",
" * @updateTime <%= pkg.today('Y-m-d') %>",
" */",
"\r\n"].join("\r\n");
var headerCommentInline = "/*! <%= pkg.name %> v<%= pkg.version %> | <%= fileName(file) %> | <%= pkg.description %> | MIT License | By: <%= pkg.author %> | <%= pkg.homepage %> | <%=pkg.today('Y-m-d') %> */\n";
gulp.task('scss', function() {
var src = [
'src/scss/planeui.scss',
'src/scss/planeui.logo.scss',
'src/scss/planeui.basic.scss'
];
return gulp.src(src)
.pipe(sass({ outputStyle: 'expanded', sourcemap: false })) //nested,compact,expanded,compressed
//.pipe(autoprefixer('last 2 version', 'safari 5', 'ie 8', 'ie 9', 'opera 12.1', 'ios 6', 'android 4'))
.pipe(gulp.dest('dist/css'))
.pipe(rename({ suffix: '.min' }))
.pipe(gulp.dest('dist/css'))
.pipe(minifycss())
.pipe(gulp.dest('dist/css'))
.pipe(notify({ message: 'Scss task completed!' }));
});
gulp.task("js-concat", function() {
return gulp.src(['!src/js/module.js', '!src/js/fullpage.js', 'src/js/*.js', bowerPath + "modernizr/modernizr.js"])
.pipe(concat('planeui.js'))
.pipe(gulp.dest('dist/js'))
.pipe(notify({ message: 'JS concat task complete' }));
});
gulp.task("js-amd", ["js-concat"], function() {
return gulp.src("src/js/module.js")
.pipe(replace("// PlaneUI", fs.readFileSync("dist/js/planeui.js", "utf-8")))
.pipe(gulp.dest('dist/js'))
.pipe(rename({ basename : "planeui" }))
.pipe(gulp.dest('dist/js'))
.pipe(header(headerComment, {pkg : pkg, fileName : function(file) {
var name = file.path.split(file.base);
return name[1].replace("\\", "");
}}))
.pipe(gulp.dest('dist/js'))
.pipe(rename({ suffix: '.min' }))
.pipe(uglify())
.pipe(gulp.dest('dist/js'))
.pipe(header(headerCommentInline, {pkg : pkg, fileName : function(file) {
var name = file.path.split(file.base + "\\");
return name[1];
}}))
.pipe(gulp.dest('dist/js'))
.pipe(notify({ message: 'planeui.js task complete' }));
});
gulp.task("plugins", function() {
return gulp.src("src/plugins/**/*")
.pipe(gulp.dest("dist/plugins"))
.pipe(notify({ message: "Plugins task complete!" }));
});
// IE patch files
// Polyfills
gulp.task("ie9lte", function() {
var src = [
bowerPath + "selectivizr/selectivizr.js",
bowerPath + "html5shiv/dist/html5shiv-printshiv.js",
bowerPath + "respond/dest/respond.matchmedia.addListener.src.js"
];
return gulp.src(src)
.pipe(concat("planeui.patch.ie8.js"))
.pipe(header(headerComment, {pkg : pkg, fileName : function(file) {
var name = file.path.split(file.base);
return name[1];
}}))
.pipe(gulp.dest("dist/js"))
.pipe(rename({ suffix: '.min' }))
.pipe(uglify())
.pipe(gulp.dest('dist/js'))
.pipe(header(headerCommentInline, {pkg : pkg, fileName : function(file) {
var name = file.path.split(file.base + "\\");
return name[1];
}}))
.pipe(gulp.dest('dist/js'))
.pipe(notify({ message: "IE Patch task complete" }));
});
gulp.task("ie9patch", function() {
var src = [
bowerPath + "doctype-flexie/src/flexie.js",
"./src/js/iepatch/iepatch.js"
];
return gulp.src(src)
.pipe(concat("planeui.patch.ie9.js"))
.pipe(header(headerComment, {pkg : pkg, fileName : function(file) {
var name = file.path.split(file.base);
return name[1];
}}))
.pipe(gulp.dest("dist/js"))
.pipe(rename({ suffix: '.min' }))
.pipe(uglify())
.pipe(gulp.dest('dist/js'))
.pipe(header(headerCommentInline, {pkg : pkg, fileName : function(file) {
var name = file.path.split(file.base + "\\");
return name[1];
}}))
.pipe(gulp.dest('dist/js'))
.pipe(notify({ message: "IE Patch task complete" }));
});
gulp.task("js", ["js-amd"], function() {
return gulp.src("dist/js/module.js").pipe(clean()).pipe(notify({ message: 'js task complete!' }));
});
gulp.task("jsall", ["js-amd", "ie9lte", "ie9patch", "plugins"], function() {
return gulp.src("dist/js/module.js").pipe(clean()).pipe(notify({ message: 'jsall task complete!' }));
});
gulp.task("fonts", function(){
return gulp.src([bowerPath + "fontawesome/fonts/*"])
.pipe(gulp.dest('dist/fonts'));
});
// CSS deps
gulp.task("cssdeps", function() {
var src = [
bowerPath + "normalize.css/normalize.css",
bowerPath + "fontawesome/css/font-awesome.css",
bowerPath + "prefixes.scss/dist/prefixes.scss"
];
return gulp.src(src)
.pipe(rename({extname: ".scss"}))
.pipe(gulp.dest("src/scss/third-party"))
.pipe(notify({ message: "Dev deps css task complete" }));
});
gulp.task("dev", ["fonts", "cssdeps"]);
/*gulp.task("jsdoc", function(){
return gulp.src(["./src/*.js", "README.md"])
.pipe(jsdoc.parser())
.pipe(jsdoc.generator('./docs/html'));
});
gulp.task("jsdoc2md", function(){
return gulp.src("src/*.js")
.pipe(jsdoc2md())
.on("error", function(err){
gutil.log(gutil.colors.red("jsdoc2md failed"), err.message)
})
.pipe(rename(function(path) {
path.extname = ".md";
}))
.pipe(gulp.dest("docs/markdown"));
});*/
gulp.task('watch', function() {
gulp.watch('src/scss/**/*.scss', ['scss']);
gulp.watch('src/js/**/*.js', ['js']);
gulp.watch('./src/js/iepatch/iepatch.js', ['ie']);
});
gulp.task('default', function() {
//gutil.log(gutil);
//gutil.log(gutil.colors.green("default task starting....."));
//gulp.run('scss');
/*
gulp.watch('./src/js/*.js',function() {
gulp.run('js');
});
gulp.watch('./src/scss/*.scss',function() {
gulp.run('scss');
});*/
});