-
Notifications
You must be signed in to change notification settings - Fork 1
/
gulpfile.js
62 lines (56 loc) · 1.78 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
'use strict';
// Initialize modules
// Importing specific gulp API functions lets us write
// them below as series() instead of gulp.series().
const { src, dest, watch, series, parallel } = require('gulp');
const sass = require('gulp-sass')(require('sass'));
const rename = require('gulp-rename');
// File paths
const files = {
scssSrc: ['./scss/*.scss', '!./scss/_*.scss'],
scssWatchPath: './scss/**/*.scss',
scssDest: './stylesheets',
jsDevDependenciesBase: './node_modules',
jsDevDependenciesSrc: [
'./node_modules/bootstrap/dist/js/bootstrap.bundle.min.js',
'./node_modules/parvus/dist/js/parvus.min.js',
'./node_modules/@meom/navigation/dist/index.esm.min.js'
],
jsDevDependenciesDest: './javascripts/vendor'
};
// This task moves JS files from our `node_modules` folder to the
// root `javascripts/vendor` folder.
// It runs automatically after `npm install/ci` or can be run via
// `npm run postinstall` OR `gulp moveJsFiles`.
function moveJsFiles (done) {
src(files.jsDevDependenciesSrc, { base: files.jsDevDependenciesBase })
.pipe(rename(function (file) {
// this removes the last parent directory of the relative file path
if (file.dirname.split('/').length > 1) {
file.dirname = file.dirname.split('/')[0];
}
}))
.pipe(dest(files.jsDevDependenciesDest));
done();
}
// Sass Task
// Compile our Sass from the root `./scss` directory
function sassTask (done) {
src(files.scssSrc)
.pipe(sass.sync({ outputStyle: 'compressed' }).on('error', sass.logError))
.pipe(dest(files.scssDest));
done();
}
// Watch Task
// Watches our Sass for changes
function watchTask (done) {
watch(files.scssWatchPath,
series(sassTask)
);
done();
}
// Exports:
exports.moveJsFiles = moveJsFiles;
exports.default = series(
sassTask, watchTask
);