-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
93 lines (79 loc) · 2.05 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
var gulp = require( 'gulp' ),
$ = require( 'gulp-load-plugins' )(),
fs = require( 'fs' ),
browserSync = require( 'browser-sync' ),
pngquant = require( 'imagemin-pngquant' );
// Sassのタスク
gulp.task( 'sass', function () {
return gulp.src( [ './assets/scss/**/*.scss' ] )
.pipe( $.sass( {
errLogToConsole: true,
outputStyle: 'compressed',
sourceComments: 'normal',
includePaths: [
'./assets/scss',
'./node_modules/bootstrap-sass/assets/stylesheets',
]
} ) )
.pipe( gulp.dest( './docs/css' ) );
} );
// Image min
gulp.task( 'imagemin', function () {
return gulp.src( './assets/img/**/*' )
.pipe( $.imagemin( {
progressive: true,
svgoPlugins: [ { removeViewBox: false } ],
use: [ pngquant() ]
} ) )
.pipe( gulp.dest( './docs/img' ) );
} );
// Jade
gulp.task( 'pug', function () {
var list = fs.readdirSync( './assets/pug' )
.filter( function ( file ) {
return /^[^_].*\.pug$/.test( file );
} ).map( function ( f ) {
return f.replace( '.pug', '.html' );
} );
return gulp.src( [ './assets/pug/**/*.pug', '!./assets/pug/**/_*.pug' ] )
.pipe( $.pug( {
pretty: true,
locals: {
list: list
}
} ) )
.pipe( gulp.dest( 'docs' ) );
} );
// watch
gulp.task( 'watch', function () {
// Make SASS
gulp.watch( 'assets/scss/**/*.scss', gulp.task( 'sass' ) );
// Minify Image
gulp.watch( 'assets/img/src/**/*', gulp.task( 'imagemin' ) );
// Build Jade
gulp.watch( 'assets/pug/**/*.pug', gulp.task( 'pug' ) );
// Browser sync
gulp.watch( [
'docs/css/**/*.css',
'docs/img/**/*',
'docs/*.html'
], gulp.task( 'bs-reload' ) );
} );
// Reload Browser sync
gulp.task( 'bs-reload', function () {
browserSync.reload();
} );
// BrowserSync
gulp.task( 'browser-sync', function () {
browserSync( {
server: {
baseDir: "./docs", //対象ディレクトリ
index: "index.html" //インデックスファイル
},
reloadDelay: 500,
} );
} );
// Build
gulp.task( 'build', gulp.parallel( [ 'sass', 'imagemin', 'pug' ] ) );
// Default Tasks
gulp.task( 'default', gulp.parallel( 'browser-sync', 'watch' ) );