This repository has been archived by the owner on Sep 13, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathgulpfile.js
executable file
·74 lines (67 loc) · 1.92 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
const pkg = require('./package.json')
const gulp = require('gulp')
const cssnano = require('gulp-cssnano')
const less = require('gulp-less')
const rename = require('gulp-rename')
const header = require('gulp-header')
const runSequence = require('run-sequence')
const autoprefixer = require('gulp-autoprefixer')
const size = require('gulp-size')
const cssimport = require('gulp-cssimport')
const purge = require('gulp-css-purge')
const del = require('del')
const browserSync = require('browser-sync')
const lesshint = require('gulp-lesshint')
const reload = browserSync.reload
const source = {
dist: 'src/main.less',
css: 'src/**/*.less',
demo: ['demo/*.html', 'demo/**/*.css']
}
const banner = ['/**',
' * <%= pkg.name %> - <%= pkg.description %>',
' * @version v<%= pkg.version %>',
' * @link <%= pkg.homepage %>',
' * @license <%= pkg.license %>',
' */'
].join('\n')
gulp.task('build', () => {
return gulp.src(source.dist)
.pipe(less())
.pipe(cssimport())
.pipe(purge())
.pipe(autoprefixer('last 2 versions'))
.pipe(header(banner, {pkg}))
.pipe(rename('barebones.css'))
.pipe(gulp.dest('dist'))
.pipe(cssnano())
.pipe(rename({ extname: '.min.css' }))
.pipe(header(banner, {pkg}))
.pipe(gulp.dest('demo/css'))
.pipe(gulp.dest('dist'))
.pipe(reload({stream: true}))
})
gulp.task('lint', function () {
return gulp.src(source.css)
.pipe(lesshint())
.pipe(lesshint.reporter())
.pipe(lesshint.failOnError()) // Use this to fail the task on lint errors
})
gulp.task('file-size', () => {
return gulp.src('dist/*.min.css')
.pipe(size({
gzip: true,
showFiles: true
}))
})
gulp.task('clean', () => {
return del('dist/**/*')
})
gulp.task('default', done => runSequence('clean', 'serve'))
gulp.task('serve', ['build'], function () {
browserSync({
server: './demo'
})
gulp.watch(source.css, ['build'])
gulp.watch(source.demo).on('change', reload)
})