2023-08-04 12:45:10 +01:00
|
|
|
const gulp = require('gulp');
|
2023-12-26 15:59:25 +00:00
|
|
|
const sass = require('gulp-sass')(require('sass'));
|
2023-08-04 12:45:10 +01:00
|
|
|
const cleanCSS = require('gulp-clean-css');
|
|
|
|
const rename = require('gulp-rename');
|
2023-08-04 12:55:16 +01:00
|
|
|
const ts = require('gulp-typescript');
|
|
|
|
const terser = require('gulp-terser');
|
2023-08-10 04:56:12 +01:00
|
|
|
const webpack = require('webpack-stream');
|
2023-08-04 12:45:10 +01:00
|
|
|
|
2023-08-04 12:55:16 +01:00
|
|
|
const srcDir = 'src';
|
2023-08-13 17:33:54 +01:00
|
|
|
const destDir = 'OliverBooth/wwwroot';
|
2023-08-04 12:45:10 +01:00
|
|
|
|
|
|
|
function compileSCSS() {
|
2023-08-04 12:55:16 +01:00
|
|
|
return gulp.src(`${srcDir}/scss/**/*.scss`)
|
2023-08-04 12:45:10 +01:00
|
|
|
.pipe(sass().on('error', sass.logError))
|
|
|
|
.pipe(cleanCSS({ compatibility: 'ie11' }))
|
|
|
|
.pipe(rename({ suffix: '.min' }))
|
2023-08-04 12:55:16 +01:00
|
|
|
.pipe(gulp.dest(`${destDir}/css`));
|
|
|
|
}
|
|
|
|
|
|
|
|
function compileTS() {
|
2023-08-10 14:34:01 +01:00
|
|
|
return gulp.src(`${srcDir}/ts/**/*.ts`)
|
2023-08-10 04:56:12 +01:00
|
|
|
.pipe(ts("tsconfig.json"))
|
2023-08-04 12:55:16 +01:00
|
|
|
.pipe(terser())
|
2023-08-10 04:56:12 +01:00
|
|
|
.pipe(gulp.dest(`tmp/js`));
|
2023-08-10 14:34:01 +01:00
|
|
|
}
|
2023-08-10 04:56:12 +01:00
|
|
|
|
2023-08-10 14:34:01 +01:00
|
|
|
function bundleJS() {
|
2023-08-10 04:56:12 +01:00
|
|
|
return gulp.src('tmp/js/*.js')
|
|
|
|
.pipe(webpack({ mode: 'production', output: { filename: 'app.min.js' } }))
|
2023-08-04 12:55:16 +01:00
|
|
|
.pipe(gulp.dest(`${destDir}/js`));
|
2023-08-04 12:45:10 +01:00
|
|
|
}
|
|
|
|
|
2023-08-08 01:20:11 +01:00
|
|
|
function copyJS() {
|
|
|
|
return gulp.src(`${srcDir}/ts/**/*.js`)
|
|
|
|
.pipe(rename({ suffix: '.min' }))
|
|
|
|
.pipe(gulp.dest(`${destDir}/js`));
|
|
|
|
}
|
|
|
|
|
|
|
|
function copyCSS() {
|
|
|
|
return gulp.src(`${srcDir}/scss/**/*.css`)
|
|
|
|
.pipe(rename({ suffix: '.min' }))
|
|
|
|
.pipe(gulp.dest(`${destDir}/css`));
|
|
|
|
}
|
|
|
|
|
2023-08-06 16:05:44 +01:00
|
|
|
function copyImages() {
|
|
|
|
return gulp.src(`${srcDir}/img/**/*.*`)
|
|
|
|
.pipe(gulp.dest(`${destDir}/img`));
|
|
|
|
}
|
|
|
|
|
2024-02-29 18:15:07 +00:00
|
|
|
exports.assets = copyImages;
|
|
|
|
exports.styles = gulp.parallel(compileSCSS, copyCSS);
|
|
|
|
exports.scripts = gulp.parallel(copyJS, gulp.series(compileTS, bundleJS));
|
|
|
|
|
|
|
|
exports.default = gulp.parallel(exports.styles, exports.scripts, exports.assets);
|