This repository has been archived by the owner on Dec 25, 2023. It is now read-only.
forked from electerious/basicContext
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
75 lines (68 loc) · 1.95 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
"use strict";
const name = require("./package.json").moduleName;
const gulp = require("gulp");
const browserify = require("browserify");
const babelify = require("babelify");
const source = require("vinyl-source-stream");
const buffer = require("vinyl-buffer");
const uglify = require("gulp-uglify");
const sass = require("gulp-sass")(require("sass"));
const rename = require("gulp-rename");
const autoprefixer = require("gulp-autoprefixer");
const csso = require("gulp-csso");
const catchError = function (err) {
console.log(err.toString());
this.emit("end");
};
gulp.task("scripts", function () {
return browserify({
entries: "./src/scripts/basicContext.js",
standalone: name,
})
.transform(
babelify.configure({
presets: ["@babel/preset-env"],
})
)
.bundle()
.on("error", catchError)
.pipe(source(name + ".min.js"))
.pipe(buffer())
.pipe(uglify())
.on("error", catchError)
.pipe(gulp.dest("./dist"));
});
gulp.task("styles", function () {
return gulp
.src("./src/styles/main.scss")
.pipe(sass())
.on("error", catchError)
.pipe(rename((path) => (path.basename = name + ".min")))
.pipe(autoprefixer("last 2 version", "> 1%"))
.pipe(csso({ restructure: false }))
.pipe(gulp.dest("./dist"));
});
gulp.task("addons", function () {
return gulp
.src("./src/styles/addons/*.scss")
.pipe(sass())
.on("error", catchError)
.pipe(rename((path) => (path.basename = path.basename + ".min")))
.pipe(autoprefixer("last 2 version", "> 1%"))
.pipe(csso({ restructure: false }))
.pipe(gulp.dest("./dist/addons"));
});
gulp.task("themes", function () {
return gulp
.src("./src/styles/themes/*.scss")
.pipe(sass())
.on("error", catchError)
.pipe(rename((path) => (path.basename = path.basename + ".min")))
.pipe(autoprefixer("last 2 version", "> 1%"))
.pipe(csso({ restructure: false }))
.pipe(gulp.dest("./dist/themes"));
});
gulp.task(
"default",
gulp.series(gulp.parallel("scripts", "styles", "addons", "themes"))
);