This repository has been archived by the owner on Nov 5, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
gulpfile.babel.js
85 lines (73 loc) · 1.66 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
83
84
85
import browserSync from 'browser-sync';
import { argv } from 'yargs';
import { dest, series, src, watch } from 'gulp';
import sass from 'gulp-sass';
import sourcemaps from 'gulp-sourcemaps';
/**
* Environment check
*/
const { production } = argv;
/**
* Main Dirs
*/
const DIR_APP_ROOT = '.';
const DIR_DIST = `${DIR_APP_ROOT}/dist`;
//const DIR_JS = `${DIR_APP_ROOT}/js`;
const DIR_PLAYGROUND = `${DIR_APP_ROOT}/playground`;
const DIR_SCSS = `${DIR_APP_ROOT}/scss`;
/**
* Paths
*/
const PATHS = {
browserSync: {
src: DIR_PLAYGROUND,
},
playground:{
src: `${DIR_PLAYGROUND}/**/*.html`
},
scss: {
src: `${DIR_SCSS}/**/*.{sass,scss}`,
dest: {
dev: `${DIR_PLAYGROUND}/css`,
production: `${DIR_DIST}`,
},
},
};
/**
* Settings
*/
const SETTINGS = {
browserSync: {
server: {
baseDir: PATHS.browserSync.src,
},
open: false,
},
scss: {
includePaths: ['node_modules/foundation-sites/scss']
}
};
/**
* Helper Functions
*/
const ifProdElseDev = (prod, notProd) => production ? prod : notProd;
/**
* Gulp Task Functions
*/
export const buildScss = (cb) => src(PATHS.scss.src)
.pipe(sourcemaps.init())
.pipe(sass(SETTINGS.scss).on('error', sass.logError))
.pipe(sourcemaps.write())
.pipe(dest(ifProdElseDev(PATHS.scss.dest.production, PATHS.scss.dest.dev)))
.pipe(browserSync.stream());
export const build = series(buildScss);
export const startServer = (cb) => {
browserSync.init(SETTINGS.browserSync);
watch(PATHS.scss.src, buildScss);
watch(PATHS.playground.src).on('change', browserSync.reload);
}
export const devPlayground = series(
build,
startServer,
)
export default devPlayground;