-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.babel.js
82 lines (73 loc) · 2.56 KB
/
gulpfile.babel.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
'use strict';
// GUlp is a simple platform-agnostic toolkit that helps you automate painful
// and time-consuming tasks in your workflow
import gulp from 'gulp';
import fs from 'fs';
// browser-sync - Live CSS Reload & Browser Syncing
import browserSyncLib from 'browser-sync';
// minimist - argument parser without all the fanciful decoration
import minimist from 'minimist';
// gulp-load-plugins - Loads gulp plugins from package dependencies and attaches
// them to an object of your choice.
import gulpLoadPlugins from 'gulp-load-plugins';
// Import package.json to grab and use the config property
import packageJsonData from './package.json';
import clean from './gulp/clean';
import copy from './gulp/copy';
import deploy from './gulp/deploy';
import font from './gulp/font';
import image from './gulp/image';
import pug from './gulp/pug';
import sass from './gulp/sass';
import template from './gulp/template';
import watch from './gulp/watch';
const config = Object.assign({}, packageJsonData.config);
const args = minimist(process.argv.slice(2));
const dir = config.directory;
const taskTarget = args.production ? dir.production : dir.development;
// Create a new browserSync instance
const browserSync = browserSyncLib.create();
// Load gulp plugins
const plugins = gulpLoadPlugins({
// when set to true, the plugin will log info to console.
// Useful for bug reporting and issue debugging
DEBUG: false
});
// Read all files from the gulp folder and load all gulp tasks
// fs.readdirSync('./gulp')
// .filter(fileName => /\.(js)$/i.test(fileName))
// .map(fileName => fileName.split('.').reduce(a=>a)());
clean({ gulp, config, args, taskTarget, plugins, browserSync });
copy({ gulp, config, args, taskTarget, plugins, browserSync });
deploy({ gulp, config, args, taskTarget, plugins, browserSync });
font({ gulp, config, args, taskTarget, plugins, browserSync });
image({ gulp, config, args, taskTarget, plugins, browserSync });
pug({ gulp, config, args, taskTarget, plugins, browserSync });
sass({ gulp, config, args, taskTarget, plugins, browserSync });
template({ gulp, config, args, taskTarget, plugins, browserSync });
watch({ gulp, config, args, taskTarget, plugins, browserSync });
// Server task with watch
gulp.task('dev', gulp.series(
'clean:development',
'font',
'copy',
'image',
'sass',
'pug',
'template',
'watch'
));
// Build production ready code
gulp.task('build', gulp.series(
'clean:production',
'font',
'copy',
'image',
'sass',
'pug',
'template'
));
// Default gulp task
gulp.task('default', () => {
console.log('Default gulp task');
});