Mango/gulpfile.js

75 lines
1.8 KiB
JavaScript
Raw Normal View History

2020-02-17 01:50:44 +00:00
const gulp = require('gulp');
2020-09-22 07:40:47 +00:00
const babel = require('gulp-babel');
const minify = require('gulp-babel-minify');
2020-02-17 01:50:44 +00:00
const minifyCss = require('gulp-minify-css');
2020-06-16 05:15:39 +00:00
const less = require('gulp-less');
2020-02-17 01:50:44 +00:00
gulp.task('copy-img', () => {
2020-09-22 08:46:53 +00:00
return gulp.src('node_modules/uikit/src/images/backgrounds/*.svg')
.pipe(gulp.dest('public/img'));
2020-09-17 13:15:28 +00:00
});
gulp.task('copy-font', () => {
2021-02-11 08:40:24 +00:00
return gulp.src('node_modules/@fortawesome/fontawesome-free/webfonts/fa-solid-900.woff**')
.pipe(gulp.dest('public/webfonts'));
});
// Copy files from node_modules
gulp.task('node-modules-copy', gulp.parallel('copy-img', 'copy-font'));
2020-09-22 08:46:53 +00:00
// Compile less
gulp.task('less', () => {
return gulp.src([
'public/css/mango.less',
'public/css/tags.less'
])
2020-09-22 08:46:53 +00:00
.pipe(less())
.pipe(gulp.dest('public/css'));
});
2020-09-17 13:15:28 +00:00
2020-09-22 08:46:53 +00:00
// Transpile and minify JS files and output to dist
2020-09-22 07:40:47 +00:00
gulp.task('babel', () => {
2020-09-22 08:46:53 +00:00
return gulp.src(['public/js/*.js', '!public/js/*.min.js'])
2020-09-22 07:40:47 +00:00
.pipe(babel({
presets: [
['@babel/preset-env', {
targets: '>0.25%, not dead, ios>=9'
}]
],
}))
2020-02-24 15:45:05 +00:00
.pipe(minify({
removeConsole: true,
builtIns: false
2020-02-24 15:45:05 +00:00
}))
2020-02-17 01:50:44 +00:00
.pipe(gulp.dest('dist/js'));
});
2020-09-22 08:46:53 +00:00
// Minify CSS and output to dist
2020-02-17 01:50:44 +00:00
gulp.task('minify-css', () => {
return gulp.src('public/css/*.css')
.pipe(minifyCss())
.pipe(gulp.dest('dist/css'));
});
2020-09-22 08:46:53 +00:00
// Copy static files (includeing images) to dist
2020-06-18 15:09:18 +00:00
gulp.task('copy-files', () => {
return gulp.src([
'public/*.*',
2022-03-11 13:44:16 +00:00
'public/img/**',
'public/webfonts/*',
'public/js/*.min.js'
], {
2020-09-22 08:46:53 +00:00
base: 'public'
})
2020-02-17 14:53:01 +00:00
.pipe(gulp.dest('dist'));
});
2020-09-22 08:46:53 +00:00
// Set up the public folder for development
gulp.task('dev', gulp.parallel('node-modules-copy', 'less'));
2020-09-22 08:46:53 +00:00
// Set up the dist folder for deployment
gulp.task('deploy', gulp.parallel('babel', 'minify-css', 'copy-files'));
2020-07-19 13:53:50 +00:00
2020-09-22 08:46:53 +00:00
// Default task
gulp.task('default', gulp.series('dev', 'deploy'));