-
Notifications
You must be signed in to change notification settings - Fork 2
/
gulpfile.js
55 lines (48 loc) · 1.3 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
const gulp = require('gulp')
// サーバ
const browserSync = require('browser-sync')
// ファイル操作
const concat = require('gulp-concat')
const sourcemaps = require('gulp-sourcemaps')
// CSS
const postcss = require('gulp-postcss')
const autoprefixer = require('autoprefixer')
const uncss = require('postcss-uncss')
const cleancss = require('postcss-clean')
// サーバのセットアップ
gulp.task('browser-sync', () => {
browserSync.init({
server: {
baseDir: './',
directory: true,
},
port: 50525,
open: true,
notify: false,
})
gulp.watch('./_src/**/*.css', gulp.task(['css']))
gulp.watch('./**/*.html').on('change', browserSync.reload)
})
// Normalize.css更新用
gulp.task('update-normalize', () => {
return gulp.src('node_modules/normalize.css/normalize.css')
.pipe(gulp.dest('_src/css'))
})
// CSSの生成
gulp.task('css', () => {
return gulp.src([
'_src/css/normalize.css',
'_src/css/style.css'
])
.pipe(sourcemaps.init())
.pipe(concat('style.css'))
.pipe(postcss([
autoprefixer({ cascade: false }),
uncss({ html: ['index.html'] }),
cleancss({ keepBreaks: true, advanced: false }),
]))
.pipe(sourcemaps.write('./'))
.pipe(gulp.dest('css'))
.pipe(browserSync.stream())
})
gulp.task('default', gulp.task(['browser-sync']))