-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
55 lines (48 loc) · 1.58 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
// -------------------- Required modules --------------------
var { task, src, dest, watch, series, parallel } = require('gulp'),
concat = require('gulp-concat'),
chmod = require('gulp-chmod'),
plumber = require('gulp-plumber'),
postcss = require('gulp-postcss'),
sass = require('gulp-sass'),
autoprefixer = require('autoprefixer'),
cssnano = require('cssnano'),
removeSourcemaps = require('gulp-remove-sourcemaps');
sass.compiler = require('node-sass');
// -------------------- Configure object --------------------
var config = {};
config.src = './src';
config.JS = config.src + '/js';
config.SCSS = config.src + '/scss';
config.CSS = config.src + '/css';
config.buildTasks = ['sass', 'js'];
config.jsFiles = ['node_modules/jquery/dist/jquery.min.js', 'node_modules/popper.js/dist/umd/popper.min.js', 'node_modules/bootstrap/dist/js/bootstrap.min.js'];
// -------------------- Gulp Tasks --------------------
// Compile SASS into CSS
task('sass', function() {
var plugins = [
autoprefixer(),
cssnano()
];
return src(config.SCSS +'/*.scss')
.pipe(plumber())
.pipe(sass())
.pipe(postcss(plugins))
.pipe(chmod(0o755))
.pipe(dest(config.CSS))
});
// Move the JS files into our /src/js folder
task('js', function() {
return src(config.jsFiles)
.pipe(plumber())
.pipe(removeSourcemaps())
.pipe(concat('vendor.js'))
.pipe(dest(config.JS))
});
// Watches scss files
task('watch', series('sass', function(done) {
watch([config.SCSS + '/*.scss', config.SCSS + '/_*.scss'], series('sass'));
done();
}));
task('build', series(config.buildTasks));
task('default', series('watch'));