/
gulpfile.js
128 lines (110 loc) · 3.42 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
var gulp = require('gulp'),
watch = require('gulp-watch'),
sass = require('gulp-sass'),
concat = require('gulp-concat'),
rename = require("gulp-rename"),
run = require('gulp-run-electron'),
include = require('gulp-file-include'),
htmlmin = require('gulp-html-minifier');
htmlRC = require('gulp-remove-html-comments');
del = require('del'),
i18n = ['es', 'en']
var paths = {
scripts:[
'./node_modules/admin-lte/bootstrap/js/bootstrap.min.js', //> Bootstrap 3.3.5
'./node_modules/admin-lte/dist/js/app.min.js', //> AdminLTE
'./node_modules/admin-lte/plugins/slimScroll/jquery.slimscroll.min.js', //> SlimScroll 1.3.0
'./node_modules/admin-lte/plugins/fastclick/fastclick.min.js' //> FastClick
],
datatable:[
'./node_modules/admin-lte/plugins/datatables/jquery.dataTables.min.js',
'./node_modules/admin-lte/plugins/datatables/dataTables.bootstrap.min.js'
],
styles: [
'./node_modules/admin-lte/bootstrap/css/bootstrap.min.css', //> Bootstrap 3.3.5
'./node_modules/admin-lte/plugins/datatables/dataTables.bootstrap.css', //> DataTables
'./node_modules/admin-lte/dist/css/AdminLTE.css' //> Theme style
],
app: [
'package.json',
'app/**/*',
'!app/{tpl,tpl/**}',
'!app/{sass,sass/**}',
'!app/{icons/svg,icons/svg/**}'
],
sass: [
'app/sass/**/*',
],
fonts: [
'./node_modules/font-awesome/fonts/*',
'./node_modules/font-awesome/css/*'
],
skins: [
'./node_modules/admin-lte/dist/css/skins/_all-skins.min.css'
],
}
////////////////////////
///////-- Dist --///////
////////////////////////
gulp.task('dist:clean', function() {
return del(['dist'])
})
gulp.task('dist:html', ['dist:clean'], function() {
for (var loc in i18n) {
var locale = require('./app/json/locale/' + i18n[loc] + '.json'),
config = {
prefix: '{{',
suffix: '}}',
basepath: '@file',
context: locale
}
gulp.src(['./app/tpl/index.html'])
.pipe(include(config))
.pipe(rename({ suffix: '-' + i18n[loc] }))
.pipe(htmlRC())
.pipe(htmlmin({collapseWhitespace: true}))
.pipe(gulp.dest('dist/'))
}
})
gulp.task('dist:scripts', ['dist:clean'], function() {
return gulp.src(paths.scripts)
.pipe(concat('libs.js'))
.pipe(gulp.dest('dist/js/'))
})
gulp.task('dist:styles', ['dist:clean'], function() {
gulp.src(paths.sass)
.pipe(sass().on('error', sass.logError))
.pipe(gulp.dest('dist/css/'))
gulp.src(paths.skins)
.pipe(gulp.dest('dist/css/'))
gulp.src(paths.styles)
.pipe(concat('libs.css'))
.pipe(gulp.dest('dist/css/'))
})
gulp.task('dist:copy', ['dist:clean'], function (){
return gulp.src(paths.app)
.pipe(gulp.dest('dist/'))
})
gulp.task('dist:fonts', ['dist:clean'], function (){
return gulp.src(paths.fonts, { base: './node_modules/font-awesome/' })
.pipe(gulp.dest('dist/icons/fonts/font-awesome/'))
})
gulp.task('dist', ['dist:copy', 'dist:html', 'dist:styles', 'dist:fonts', 'dist:scripts'])
////////////////////////
//////-- relese --//////
////////////////////////
var version = "0.1.0-Alpha"
gulp.task('copile:clean', function() {
del(['relese/' + version + '/'])
})
gulp.task('compile', ['copile:clean'])
////////////////////////
//////-- Basic --///////
////////////////////////
gulp.task('run', ['dist'], function(){
return gulp.src("dist").pipe(run())
})
gulp.task('watch', ['run'], function(){
return gulp.watch('./app/**/*', [run.rerun])
})
gulp.task('default', ['run'])