-
Notifications
You must be signed in to change notification settings - Fork 1
/
Gulpfile.js
57 lines (48 loc) · 1.2 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
const gulp = require('gulp')
const less = require('gulp-less')
const plumber = require('gulp-plumber')
const cleanCSS = require('gulp-clean-css')
// css
const postcss = require('gulp-postcss')
// HACK
const concat = require('gulp-concat')
const inject = require('gulp-inject-string')
// ENV
const env = process.env.NODE_ENV || 'development'
const prod = env === 'production'
// GLOBAL CSS
const paths = {
css: [
'./node_modules/normalize.css/normalize.css',
'./styles/site.css',
'./styles/styles.css'
],
styles: 'styles'
}
gulp.task('css', () => {
let plugins = [
require('precss')({}), // eslint-disable-line
require('autoprefixer')({}) // eslint-disable-line
]
if (prod) {
plugins = [
require('cssnano') // eslint-disable-line
].concat(plugins)
}
const header = `module.exports = \``
const footer = `\``
return (
gulp
.src(paths.css)
.pipe(plumber())
// .pipe(postcss(plugins))
.pipe(cleanCSS({ format: 'beautify' }))
.pipe(concat('global-styles.js'))
.pipe(inject.prepend(header))
.pipe(inject.append(footer))
.pipe(gulp.dest(paths.styles))
)
})
gulp.task('dev', () => {
gulp.watch([paths.css], ['css'])
})