-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
99 lines (95 loc) · 2.04 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
const loadTasks = require('./gulp/load-tasks');
const loadPlugins = require('gulp-load-plugins');
const resolve = require('path').resolve;
const joinDir = (mainDir) => {
return (subDir) => {
return subDir ? resolve(mainDir, subDir) : resolve(mainDir);
};
};
/**
* Resolve main directories.
*/
const assetsDir = joinDir('assets');
const buildDir = joinDir('build');
const publicDir = joinDir('public');
const pagesDir = joinDir('pages');
/**
* Load environment variables from .env file.
*/
require('dotenv').config();
loadTasks({
/**
* Settings to load tasks.
*/
tasksDir: joinDir('gulp/tasks/'),
plugins: loadPlugins(),
/**
* General options for all tasks.
*/
options: {
debug: true,
live: !process.env.NODE_ENV || process.env.NODE_ENV === 'development',
},
/**
* Options for tasks.
*/
tasks: {
'browser-sync': {
init: {
server: {
baseDir: buildDir(),
index: 'home.html',
},
open: false,
ui: false,
notify: false,
},
watch: buildDir('**/*'),
},
clean: {
dest: buildDir(),
},
fonts: {
src: assetsDir('fonts/**/*'),
dest: buildDir('assets/fonts/'),
watch: assetsDir('fonts/**/*'),
},
js: {
src: assetsDir('js/**/*.{js,json}'),
main: 'main.js',
dest: buildDir('assets/js/'),
watch: assetsDir('js/**/*.{js,json}'),
},
public: {
src: publicDir('**/*'),
dest: buildDir(),
watch: publicDir('**/*'),
},
pug: {
src: pagesDir('*.pug'),
data: {
env: process.env,
},
dest: buildDir(),
watch: pagesDir('**/*.pug'),
},
sass: {
src: assetsDir('sass/main.scss'),
postcss: {
autoprefixer: {
cascade: false,
},
cssnano: {
preset: 'default',
},
fontMagician: {
hosted: [
assetsDir('fonts/'),
],
},
},
dest: buildDir('assets/css/'),
watch: assetsDir('sass/**/*.{scss,css}'),
},
},
});