-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
79 lines (67 loc) · 2.05 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
const gulp = require('gulp'),
less = require('gulp-less'),
sourcemaps = require('gulp-sourcemaps'),
path = require('path'),
concat = require('gulp-concat'),
rename = require('gulp-rename'),
uglify = require('gulp-uglify'),
theme = require('./theme.js'),
cleanCSS = require('gulp-clean-css');
const colors = theme.configs.colors;
const colorNames = Object.keys(colors);
const taskNames = [];
colorNames.forEach( (name)=> {
const taskName = 'less_'+name;
taskNames.push(taskName);
gulp.task( taskName, function () {
return gulp.src('./files/less/style-'+name+'.less')
.pipe( sourcemaps.init() )
.pipe(less({
paths: [
path.join(__dirname, 'files', 'less', name),
path.join(__dirname, 'files', 'less', 'theme')
]
}))
// source code:
.pipe(rename('style-'+name+'-source.css'))
.pipe(gulp.dest('./files/public/'))
// minifyed code:
.pipe(rename('style-'+name+'.css'))
.pipe(cleanCSS({
level: { 1: { specialComments: 0 } },
compatibility: 'ie8'
}))
.pipe(sourcemaps.write('./', {
sourceMappingURLPrefix: '/public/theme/one-page-new-age'
}))
.pipe(gulp.dest('./files/public/'));
});
gulp.task(taskName+'_watch', function () {
gulp.watch('files/less/**/*.less', [taskName]);
});
});
// -- JS
const jsFiles = [
path.join(__dirname, 'bower_components/matchHeight/dist/jquery.matchHeight.js'),
path.join(__dirname, 'bower_components/bootstrap/dist/js/bootstrap.js'),
path.join(__dirname, 'files', 'scripts', '**/*.js')
];
gulp.task('js', function() {
return gulp.src(jsFiles)
.pipe(concat('script.js'))
.pipe(gulp.dest('./files/public/'))
.pipe(rename('script.min.js'))
.pipe(uglify())
.pipe( gulp.dest('./files/public/') );
});
// -- Assets
gulp.task('fonts', function() {
gulp.src('./bower_components/bootstrap/fonts/**/*')
.pipe(gulp.dest('./files/public/fonts'));
});
// --
gulp.task('watch', function () {
gulp.watch('files/less/**/*.less', ['less']);
});
gulp.task('less', taskNames);
gulp.task('default', ['less', 'js', 'fonts', 'watch']);