-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
60 lines (54 loc) · 1.78 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
const gulp = require('gulp'),
sourcemaps = require('gulp-sourcemaps'),
autoprefixer = require('gulp-autoprefixer'),
less = require('gulp-less'),
LessPrefix = require('less-plugin-autoprefix'),
cssnano = require('gulp-cssnano'),
rename = require('gulp-rename'),
argv = require('yargs').argv;
const prefixOpt = {browsers: ['last 2 versions']};
gulp.task('theme', () => {
let name = argv.name,
cleanName = name.replace('_', '');
return gulp.src('./less/themes/' + name + '.less')
.pipe(less({
plugins: [new LessPrefix(prefixOpt)]
}))
.pipe(rename('components-' + cleanName + '.theme.css'))
.pipe(gulp.dest('./css'))
.on('end', () => {
console.log("Emitted file: components-" + cleanName + '.theme.css');
})
});
gulp.task('components', () => {
gulp.src('./less/components.less')
.pipe(less({
plugins: [new LessPrefix(prefixOpt)]
}))
.pipe(rename('components-alone.css'))
.pipe(gulp.dest('./css'))
.on('end', () => {
console.log("Emitted file: components-alone.css");
});
});
gulp.task('compile', () => {
gulp.src('./less/all.less')
.pipe(rename('components.css'))
.pipe(sourcemaps.init())
.pipe(less({
plugins: [new LessPrefix(prefixOpt)]
}))
.pipe(sourcemaps.write('./'))
.pipe(gulp.dest('./css'))
});
gulp.task('minify', () => {
gulp.src(['./css/*.css', '!./css/*.min.css'])
.pipe(cssnano())
.pipe(rename({
suffix: '.min'
}))
.pipe(gulp.dest('./css/'))
});
gulp.task('default', ['less:compile', 'css:minify'], () => {
console.log('Compiling and minify all');
});