-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathgulpfile.js
More file actions
153 lines (137 loc) · 4.15 KB
/
gulpfile.js
File metadata and controls
153 lines (137 loc) · 4.15 KB
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
var gulp = require('gulp');
var sass = require('gulp-sass');
var csso = require('gulp-csso');
var uglify = require('gulp-uglify');
var concat = require('gulp-concat');
var plumber = require('gulp-plumber');
var coffee = require('gulp-coffee');
var gutil = require('gulp-util');
var clean = require('gulp-clean');
var coffeelint = require('gulp-coffeelint');
var webserver = require('gulp-webserver');
var opn = require('opn');
var del = require('del');
var basePaths = {
frontend: './sqliteweb-web',
server: './sqliteweb-server'
};
var paths = {
src: {
js: [
basePaths.frontend + '/bower_components/jquery/dist/jquery.js',
basePaths.frontend + '/bower_components/bootstrap-sass-official/assets/javascripts/bootstrap.js',
basePaths.frontend + '/bower_components/lodash/dist/lodash.js',
basePaths.frontend + '/js/*.js',
'!sqliteweb-web/js/app.min.js'
],
coffee: [
basePaths.frontend + '/js/app.coffee'
],
css: [
basePaths.frontend + '/css/app.scss'
],
fonts: [
basePaths.frontend + '/bower_components/font-awesome/fonts/*'
],
dist: [
basePaths.frontend + '/js/*.min.js',
basePaths.frontend + '/css/*.css',
basePaths.frontend + '/fonts/*',
basePaths.frontend + '/*.html',
basePaths.frontend + '/vendor/ace/**/*',
'!sqliteweb-web/bower_components'
]
},
dest: {
css: basePaths.frontend + '/css',
js: basePaths.frontend + '/js',
fonts: basePaths.frontend + '/fonts',
dist: basePaths.server + '/static'
},
clean: {
dev: [
basePaths.frontend + '/js/*.js',
basePaths.frontend + '/css/*.css',
basePaths.frontend + '/fonts/*'
],
dist: [
basePaths.server + '/static/js/*.js',
basePaths.server + '/static/css/*.css',
basePaths.server + '/static/*.html',
basePaths.server + '/static/ace/**/*.js'
]
}
};
var server = {
host: 'localhost',
port: '8001'
};
// Clean local dev files
gulp.task('clean', function(cb) {
del(paths.clean.dev);
});
// Clean dist files
gulp.task('cleanDist', function () {
del(paths.clean.dist);
});
gulp.task('sass', function() {
gulp.src(paths.src.css)
.pipe(plumber())
.pipe(sass())
.pipe(csso())
.pipe(gulp.dest(paths.dest.css));
});
// Lint Coffeescript files
gulp.task('lint', function () {
gulp.src(paths.src.coffee)
.pipe(coffeelint())
.pipe(coffeelint.reporter())
});
// Compile Coffeescript files
gulp.task('coffee', function() {
gulp.src(paths.src.coffee)
.pipe(coffee({bare: true}).on('error', gutil.log))
.pipe(gulp.dest(paths.dest.js));
});
gulp.task('compress', function() {
gulp.src(paths.src.js)
.pipe(concat('app.min.js'))
.pipe(uglify())
.pipe(gulp.dest(paths.dest.js));
});
gulp.task('watch', function() {
gulp.watch('sqliteweb-web/css/*.scss', ['sass']);
gulp.watch(['sqliteweb-web/js/*.coffee'], ['lint', 'coffee', 'compress']);
});
gulp.task('watchDist', function() {
gulp.watch('sqliteweb-web/css/*.scss', ['sass']);
gulp.watch(['sqliteweb-web/js/*.coffee'], ['lint', 'coffee', 'compress']);
gulp.watch(['sqliteweb-web/css/app.css',
'sqliteweb-web/js/app.min.js',
'sqliteweb-web/index.html'], ['cleanDist', 'copyDistFiles']);
});
gulp.task('webserver', function() {
gulp.src('sqliteweb-web')
.pipe(webserver({
host: server.host,
port: server.port,
livereload: true,
directoryListing: false
}));
});
gulp.task('openbrowser', function() {
opn( 'http://' + server.host + ':' + server.port );
});
// Copy all fonts to the public folder
gulp.task('fonts', function() {
gulp.src(paths.src.fonts)
.pipe(gulp.dest(paths.dest.fonts));
});
// Copy all dist files to the server folder.
gulp.task('copyDistFiles', function () {
gulp.src(paths.src.dist, {base: "./sqliteweb-web"})
.pipe(gulp.dest(paths.dest.dist));
});
gulp.task('default', ['clean', 'sass', 'lint', 'coffee', 'compress', 'fonts', 'webserver', 'watch', 'openbrowser']);
gulp.task('dev', ['sass', 'lint', 'coffee', 'compress', 'fonts', 'cleanDist', 'copyDistFiles', 'watchDist']);
gulp.task('dist', ['sass', 'lint', 'coffee', 'compress', 'fonts', 'cleanDist', 'copyDistFiles']);