-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
95 lines (85 loc) · 2.05 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
// Util
const gulp = require('gulp');
const flatmap = require('gulp-flatmap');
// Sass
const sass = require('gulp-sass');
const autoprefixer = require('gulp-autoprefixer');
// JS
const rollup = require('rollup');
const rollupEach = require('gulp-rollup-each');
const rollupResolve = require('@rollup/plugin-node-resolve');
const rollupBabel = require('@rollup/plugin-babel');
const rollupCommon = require('@rollup/plugin-commonjs');
const rollupESLint = require('@rollup/plugin-eslint');
const uglify = require('gulp-uglify');
// // Definitions
// let production = yargs.production ? yargs.production : false;
// //
// // Check to see if a .gulp-config.json file exists, if
// // not, creates one from .ex-gulp-config.json
// //
// const setProductionTrue = done => {
// production = true;
// done();
// };
const compileSass = (stream, css_dest_path) => {
return (
stream
.pipe(
sass({
includePaths: ['node_modules'],
}).on('error', sass.logError)
)
.pipe(
autoprefixer({
grid: true,
})
)
.pipe(gulp.dest(css_dest_path))
)
};
gulp.task('sass', () => {
return gulp
.src('src/scss/*.scss')
.pipe(
flatmap(stream => {
return compileSass(stream, 'assets/');
})
);
});
//
// Javascript
//
gulp.task('js', () => {
return gulp
.src(['src/js/*.js'])
.pipe(
rollupEach(
{
// external: [],
plugins: [
rollupCommon(),
rollupBabel.babel({
babelHelpers: 'bundled',
exclude: [/\/core-js\//],
}),
rollupResolve.nodeResolve(),
rollupESLint(),
],
},
{
format: 'es',
// globals: {}
},
rollup
)
)
.pipe(gulp.dest('assets/'));
});
//
// Watch Task
//
gulp.task('watch', () => {
gulp.watch('src/scss/**/*.scss', gulp.series('sass'));
gulp.watch('src/js/*.js', gulp.series('js'));
});