-
Notifications
You must be signed in to change notification settings - Fork 1
/
gulpfile.js
136 lines (123 loc) · 4.08 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
var gulp = require('gulp'),
sass = require('gulp-sass'),
autoprefixer = require('gulp-autoprefixer'),
minifycss = require('gulp-minify-css'),
uglify = require('gulp-uglify'),
rename = require('gulp-rename'),
concat = require('gulp-concat'),
sourcemaps = require('gulp-sourcemaps'),
livereload = require('gulp-livereload'),
connect = require('gulp-connect');
var config = {
styles: {
name: 'styles',
src: 'src/styles/**/*.sass',
dest: 'dist/styles'
},
framework: {
name: 'framework',
src: [
'src/scripts/common/functions/array.js',
'src/scripts/common/functions/object.js',
'src/scripts/common/xhr.js',
'src/scripts/common/stores/templateStore.js',
'src/scripts/common/stores/modelsStore.js',
'src/scripts/common/element.js',
'src/scripts/common/models/element.js',
'src/scripts/common/models/parentComponent.js',
'src/scripts/common/services/DI.js',
'src/scripts/common/services/dataSync.js',
'src/scripts/common/stores/componentsStore.js',
'src/scripts/common/events.js',
'src/sctipts/common/components/bindVar.js',
'src/sctipts/common/components/forEach.js',
'src/sctipts/common/components/forEachKey.js'
],
dest: 'dist/framework'
},
application: {
models: {
name: 'application.models',
src: [
'src/scripts/application/models/**/*.js'
],
dest: 'dist/application'
},
components: {
name: 'application.components',
src: [
'src/scripts/application/components/**/*.js'
],
dest: 'dist/application'
}
},
server: {
root: '',
name: 'server'
}
};
// Styles
gulp.task(config.styles.name, function () {
return gulp.src(config.styles.src)
.pipe(sourcemaps.init())
.pipe(sass({style: 'expanded'}))
.pipe(autoprefixer('last 2 version', 'safari 5', 'ie 8', 'ie 9', 'opera 12.1', 'ios 6', 'android 4'))
.pipe(rename({suffix: '.min'}))
.pipe(minifycss())
.pipe(sourcemaps.write())
.pipe(gulp.dest(config.styles.dest))
.pipe(connect.reload());
});
// Application
gulp.task(config.application.models.name, function () {
return gulp.src(config.application.models.src)
.pipe(sourcemaps.init())
.pipe(concat('application.models.js'))
.pipe(sourcemaps.write())
.pipe(gulp.dest(config.application.models.dest))
.pipe(connect.reload());
});
gulp.task(config.application.components.name, function () {
return gulp.src(config.application.components.src)
.pipe(sourcemaps.init())
.pipe(concat('application.components.js'))
.pipe(rename({suffix: '.min'}))
.pipe(sourcemaps.write())
.pipe(gulp.dest(config.application.components.dest))
.pipe(connect.reload());
});
//Framework
gulp.task(config.framework.name, function () {
return gulp.src(config.framework.src)
.pipe(sourcemaps.init())
.pipe(concat('main.js'))
.pipe(rename({suffix: '.min'}))
.pipe(uglify())
.pipe(sourcemaps.write())
.pipe(gulp.dest(config.framework.dest))
.pipe(connect.reload());
});
gulp.task(config.server.name, function () {
connect.server({
root: config.server.root,
livereload: true
});
});
// Default task
gulp.task('default', [
config.styles.name,
config.framework.name,
config.application.models.name,
config.application.components.name,
config.server.name,
'watch'
]);
// Watch
gulp.task('watch', function () {
gulp.watch(config.styles.src, [config.styles.name]);
// Watch .js files
gulp.watch(config.framework.src, [config.framework.name]);
// Watch application files
gulp.watch(config.application.components.src, [config.application.components.name]);
gulp.watch(config.application.models.src, [config.application.models.name]);
});