-
Notifications
You must be signed in to change notification settings - Fork 2
/
gulpfile.js
73 lines (67 loc) · 1.56 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
const gulp = require('gulp');
const sass = require('gulp-sass')(require('sass'));
const autoprefixer = require('gulp-autoprefixer');
const cleanCSS = require('gulp-clean-css');
const browserify = require("browserify");
const source = require("vinyl-source-stream");
const babelify = require("babelify");
const tsify = require("tsify");
const envify = require("envify");
const uglifyify = require("uglifyify")
const paths = {
style: {
src: 'src/style/*.scss',
dest: 'public/style',
},
react: {
src: 'src/events/index.tsx',
dest: 'public/script/events'
}
};
function style() {
return gulp
.src(paths.style.src)
.pipe(sass())
.pipe(autoprefixer())
.pipe(cleanCSS())
.pipe(gulp.dest(paths.style.dest));
}
function watch() {
return gulp.watch(paths.style.src, style);
}
function react() {
return browserify([paths.react.src], {
debug: process.env.NODE_ENV==="production",
})
.plugin(tsify)
.transform(envify)
.transform(babelify, {
presets: [
["@babel/preset-env", {
corejs: {
version: "3.18.3",
proposals: true,
shippedProposals: true
},
targets: {
esmodules: true
},
useBuiltIns: "usage"
}],
"@babel/preset-typescript",
"@babel/preset-react"
],
extensions: [".ts", ".tsx", ".js", ".jsx"],
only: ["src/events/**/*"],
global: true
})
.transform(uglifyify, {
global: true,
}).bundle()
.pipe(source("app.js"))
.pipe(gulp.dest(paths.react.dest))
}
exports.default = gulp.series(style, react, watch);
exports.build = style;
exports.react = react;
exports.watch = watch;