-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
149 lines (133 loc) · 4.97 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
var gulp = require('gulp');
var gutil = require('gulp-util');
var bower = require('bower');
var concat = require('gulp-concat');
var sass = require('gulp-sass');
var minifyCss = require('gulp-minify-css');
var rename = require('gulp-rename');
var sh = require('shelljs');
var sourcemaps = require('gulp-sourcemaps');
var debug = require('gulp-debug');
var mainBowerFiles = require('main-bower-files');
var gulpFilter = require('gulp-filter');
var templateCache = require('gulp-angular-templatecache');
var gulpif = require('gulp-if');
var uglify = require('gulp-uglify');
var flags = {
sourceMaps: false,
uglify: true
};
var paths = {
sass: ['./scss/**/*.scss'],
jsProject: [
"./www/js/catan/js/catan.js",
"./www/js/catan/js/hexagon.js",
"./www/js/catan/js/map.js",
"./www/js/catan/js/tools.js",
"./www/js/catan/js/ui.js",
"./www/js/catan/js/position.js",
"./www/js/catan/js/generator/generator.js",
"./www/js/catan/js/generator/generator.land.js",
"./www/js/catan/js/generator/generator.number.js",
"./www/js/catan/js/generator/generator.harbor.js",
'./www/js/**/*.js'],
jsProjectTarget: 'project.js',
jsVendorTarget: 'vendor.js',
cssProject: ['./www/css/style.css'],
cssProjectTarget: 'project.css',
cssVendorTarget: 'vendor.css',
dist: 'www/dist',
sourceMaps: 'sourcemaps/' // relative to dist path
};
gulp.task('default', ['sass']);
gulp.task('sass', function (done) {
gulp.src('./scss/ionic.app.scss')
//.pipe(gulpif(flags.sourceMaps, sourcemaps.init()))
.pipe(sass())
//.pipe(gulpif(flags.sourceMaps, sourcemaps.write()))
.pipe(gulpif(flags.uglify, minifyCss()))
.pipe(gulp.dest('./www/css/from_scss'))
.on('end', done);
});
gulp.task('watch', function () {
gulp.watch(paths.sass, ['sass']);
gulp.watch(paths.jsProject, ['js-concat-project']);
gulp.watch(paths.cssProject, ['css-concat-project']);
gulp.watch('www/templates/**/*.html', ['html-concat-templates']);
});
gulp.task('install', ['git-check'], function () {
return bower.commands.install()
.on('log', function (data) {
gutil.log('bower', gutil.colors.cyan(data.id), data.message);
});
});
gulp.task('git-check', function (done) {
if (!sh.which('git')) {
console.log(
' ' + gutil.colors.red('Git is not installed.'),
'\n Git, the version control system, is required to download Ionic.',
'\n Download git here:', gutil.colors.cyan('http://git-scm.com/downloads') + '.',
'\n Once git is installed, run \'' + gutil.colors.cyan('gulp install') + '\' again.'
);
process.exit(1);
}
done();
});
gulp.task('build', function() {
gulp.start('sass');
gulp.start('js-concat-project');
gulp.start('js-concat-vendor');
gulp.start('css-concat-project');
gulp.start('css-concat-vendor');
gulp.start('fonts-concat-vendor');
gulp.start('html-concat-templates');
});
gulp.task('js-concat-project', function () {
return gulp.src(paths.jsProject)
.pipe(gulpif(flags.sourceMaps, sourcemaps.init()))
.pipe(concat(paths.jsProjectTarget))
.pipe(gulpif(flags.uglify, uglify()))
.pipe(gulpif(flags.sourceMaps, sourcemaps.write(paths.sourceMaps)))
.pipe(gulp.dest(paths.dist));
});
gulp.task('js-concat-vendor', function () {
return gulp.src(mainBowerFiles())
.pipe(gulpFilter('**/*.js'))
.pipe(gulpif(flags.sourceMaps, sourcemaps.init()))
.pipe(concat(paths.jsVendorTarget))
.pipe(gulpif(flags.uglify, uglify()))
.pipe(gulpif(flags.sourceMaps, sourcemaps.write(paths.sourceMaps)))
.pipe(gulp.dest(paths.dist));
});
gulp.task('css-concat-project', function () {
return gulp.src(paths.cssProject)
.pipe(gulpif(flags.sourceMaps, sourcemaps.init()))
.pipe(concat(paths.cssProjectTarget))
.pipe(gulpif(flags.uglify, minifyCss()))
.pipe(gulpif(flags.sourceMaps, sourcemaps.write(paths.sourceMaps)))
.pipe(gulp.dest(paths.dist));
});
gulp.task('css-concat-vendor', function () {
return gulp.src(mainBowerFiles())
.pipe(gulpFilter('**/*.css'))
.pipe(gulpif(flags.sourceMaps, sourcemaps.init()))
.pipe(concat(paths.cssVendorTarget))
.pipe(gulpif(flags.uglify, minifyCss()))
.pipe(gulpif(flags.sourceMaps, sourcemaps.write(paths.sourceMaps)))
.pipe(gulp.dest(paths.dist));
});
gulp.task('fonts-concat-vendor', function () {
return gulp.src(mainBowerFiles())
.pipe(gulpFilter(function (file) {
return /ionic\/fonts/.test(file.path);
}))
.pipe(gulp.dest('./www/fonts/'));
});
gulp.task('html-concat-templates', function() {
gulp.src('www/templates/**/*.html')
.pipe(templateCache({
module:'templatescache', standalone: true, root: './templates/'
}))
.pipe(gulpif(flags.uglify, uglify()))
.pipe(gulp.dest('www/dist/'));
});