forked from tiaanduplessis/wenk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
122 lines (107 loc) · 2.77 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
const gulp = require('gulp');
const gulpLoadPlugins = require('gulp-load-plugins');
const browserSync = require('browser-sync');
const del = require('del');
const $ = gulpLoadPlugins();
const pkg = require('./package.json');
const reload = browserSync.reload;
// Pretty banner
const banner = ['/**',
' * <%= pkg.name %> - <%= pkg.description %>',
' * @version v<%= pkg.version %>',
' * (c) ' + new Date().getFullYear() + ' <%= pkg.author %> |',
' * @link <%= pkg.homepage %>',
' * @license <%= pkg.license %>',
' */',
' '
].join('\n');
// Default paths
const paths = {
output: 'dist/',
input: {
css: 'src/wenk.css',
less: 'src/wenk.less',
scss: 'src/wenk.scss'
}
};
// Default postcss plugins
const defaultPlugins = [
require('postcss-cssnext')()
];
// Get size of all files in output dir
gulp.task('size', () => {
return gulp.src(`${paths.output}**/*`)
.pipe($.size({
gzip: true,
showFiles: true
}));
});
// Clean output dir
gulp.task('clean', () => {
return del(`${paths.output}**/*`);
});
// Build minified CSS
gulp.task('styles:minified', () => {
return gulp.src(paths.input.css)
.pipe($.plumber())
.pipe($.postcss(defaultPlugins.concat([
require('cssnano')()
])))
.pipe($.rename({
extname: '.min.css'
}))
.pipe($.header(banner, {
pkg
}))
.pipe(gulp.dest(paths.output))
.pipe(gulp.dest('./demo'))
});
// Build CSS
gulp.task('styles', () => {
return gulp.src(paths.input.css)
.pipe($.plumber())
.pipe($.postcss(defaultPlugins))
.pipe($.header(banner, {
pkg
}))
.pipe(gulp.dest(paths.output))
});
// Less
gulp.task('styles:less', () => {
return gulp.src(paths.input.less)
.pipe($.header(banner, {
pkg
}))
.pipe(gulp.dest(paths.output))
})
// SCSS
gulp.task('styles:scss', () => {
return gulp.src(paths.input.scss)
.pipe($.header(banner, {
pkg
}))
.pipe(gulp.dest(paths.output))
})
// cssnext
gulp.task('styles:cssnext', () => {
return gulp.src(paths.input.css)
.pipe($.header(banner, {
pkg
}))
.pipe($.rename({
extname: '.cssnext.css'
}))
.pipe(gulp.dest(paths.output))
})
gulp.task('build', ['styles', 'styles:minified', 'styles:less', 'styles:scss', 'styles:cssnext']);
gulp.task('watch', () => {
gulp.watch([paths.input.css, paths.input.less, paths.input.scss], ['clean', 'build'])
});
gulp.task('demo', ['clean', 'build'], () => {
browserSync({
server: './demo'
});
gulp.watch([paths.input.css, paths.input.less, paths.input.scss], ['build']);
gulp.watch('./demo/**/*').on('change', reload);
});
gulp.task('default', ['build', 'watch']);