forked from donategifts/donategifts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
98 lines (87 loc) · 2.8 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
96
97
98
const path = require('node:path');
require('dotenv').config({
path: path.join(__dirname, './config.env'),
});
const { src, dest, series, watch, task } = require('gulp');
const prefix = require('gulp-autoprefixer');
const concat = require('gulp-concat');
const sass = require('gulp-dart-sass');
const gulpif = require('gulp-if');
const plumber = require('gulp-plumber');
const postcss = require('gulp-postcss');
const sourcemaps = require('gulp-sourcemaps');
const stripDebug = require('gulp-strip-debug');
const uglify = require('gulp-uglify');
const isDev = process.env.NODE_ENV === 'development';
const onError = (runner, done) => (error) => {
console.error(`error - ${runner}`, error);
done();
};
const onSuccess = (runner, done) => () => {
console.info(`finished - ${runner}`);
done();
};
const scss = (done) =>
src('./design/scss/style.scss')
.pipe(plumber(onError('scss', done)))
.pipe(gulpif(isDev, sourcemaps.init()))
.pipe(concat('app.min.css'))
.pipe(
sass({
outputStyle: 'compressed',
}),
)
.pipe(
prefix(['last 15 versions', '> 1%', 'ie 8', 'ie 7'], {
cascade: true,
}),
)
.pipe(gulpif(isDev, sourcemaps.write()))
.pipe(dest(path.join(__dirname, './public/css')))
.on('end', onSuccess('sass', done));
const css = (done) =>
src('./node_modules/@mantine/core/esm/index.css')
.pipe(plumber(onError('css', done)))
.pipe(gulpif(isDev, sourcemaps.init()))
.pipe(concat('vendor.min.css'))
.pipe(
postcss([
require('postcss-preset-mantine'),
require('postcss-simple-vars')({
variables: {
'mantine-breakpoint-xs': '36em',
'mantine-breakpoint-sm': '48em',
'mantine-breakpoint-md': '62em',
'mantine-breakpoint-lg': '75em',
'mantine-breakpoint-xl': '88em',
},
}),
]),
)
.pipe(gulpif(isDev, sourcemaps.write()))
.pipe(dest(path.join(__dirname, './public/css')))
.on('end', onSuccess('css', done));
const js = (done) =>
src('./js/app/**/*.js')
.pipe(plumber(onError('js', done)))
.pipe(gulpif(isDev, sourcemaps.init()))
.pipe(concat('app.min.js'))
.pipe(gulpif(!isDev, stripDebug()))
.pipe(gulpif(!isDev, uglify()))
.pipe(gulpif(isDev, sourcemaps.write()))
.pipe(dest(path.join(__dirname, './public/js')))
.on('end', onSuccess('js', done));
const bootstrap = (done) =>
src('node_modules/bootstrap/dist/js/bootstrap.bundle.js')
.pipe(plumber(onError('bootstrap', done)))
.pipe(gulpif(isDev, sourcemaps.init()))
.pipe(concat('bootstrap.min.js'))
.pipe(gulpif(!isDev, stripDebug()))
.pipe(gulpif(!isDev, uglify()))
.pipe(gulpif(isDev, sourcemaps.write()))
.pipe(dest(path.join(__dirname, './public/js')))
.on('end', onSuccess('bootstrap', done));
task('watch', () =>
watch(['./design/scss/**/*.scss', './js/**/*.js'], series(scss, css, js, bootstrap)),
);
exports.default = series(scss, css, js, bootstrap);