-
Notifications
You must be signed in to change notification settings - Fork 19
/
gulpfile.js
95 lines (84 loc) · 3.07 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
const gulp = require('gulp');
const {
series
} = require('gulp');
const sass = require('gulp-sass'); //https://www.npmjs.com/package/gulp-sass
sass.compiler = require('node-sass');
const minify = require('gulp-minify'); //https://www.npmjs.com/package/gulp-minify
const eslint = require('gulp-eslint'); //https://www.npmjs.com/package/gulp-eslint
const babel = require('gulp-babel'); //https://www.npmjs.com/package/gulp-babel
const rename = require('gulp-rename'); //https://www.npmjs.com/package/gulp-rename
//const concat = require('gulp-concat'); //to combine multiple files into one
async function scss(cb) {
//create the css from the sass files
await gulp.src('sass/tinyshell.scss')
.pipe(sass().on('error', sass.logError))
.pipe(gulp.dest('dist/css'));
cb();
};
async function lint(cb) {
// ESLint ignores files with "node_modules" paths.
// So, it's best to have gulp ignore the directory as well.
// Also, Be sure to return the stream from the task;
// Otherwise, the task may end before the stream has finished.
await gulp.src(['js/tinyshell.js', '!node_modules/**'])
// eslint() attaches the lint output to the "eslint" property
// of the file object so it can be used by other modules.
.pipe(eslint())
// eslint.format() outputs the lint results to the console.
// Alternatively use eslint.formatEach() (see Docs).
.pipe(eslint.format())
// To have the process exit with an error code (1) on
// lint error, return the stream and pipe to failAfterError last.
.pipe(eslint.failAfterError());
cb();
};
async function bbl(cb) {
await gulp.src('js/tinyshell.js')
.pipe(babel({
plugins: ["@babel/plugin-proposal-class-properties"]
}))
.pipe(minify({
compress: true,
preserveComments: 'some',
noSource: true,
mangle: false
}))
.pipe(gulp.dest('dist/js'));
cb();
};
async function fonts(cb) {
//copy the fonts to the dist/css/ folder
await gulp.src('fonts/**')
.pipe(gulp.dest('dist/fonts/'));
cb();
}
exports.lint = lint;
exports.fonts = series(fonts);
exports.scss = series(scss);
exports.build = series(bbl);
// gulp.src('js/min/tinyshell.min.js')
// .pipe(gulp.dest('dist/js/'));
// ext: {
// min: '.min.js'
// },
//copy the transpiled js to the demo folder
//minify the es5 js file then copy to the dist/js/ folder
// await gulp.src('js/tinyshell.es5.js')
// .pipe(minify({
// compress: true,
// preserveComments: 'some',
// noSource: true
// }))
// .pipe(gulp.dest('dist/tinyshell.min.js'));
//copy the css to the dist folder with the .min added to the name
// gulp.src("./css/tinyshell.css")
// .pipe(rename(function (path) {
// path.basename += ".min";
// }))
// .pipe(gulp.dest("./dist/css/"));
//convert the expanded version of the sass to the css folder with all the comments not compressed
// await sass('sass/tinyshell.scss', {
// style: 'expanded'
// })
// .pipe(gulp.dest('css/'));