-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
76 lines (67 loc) · 1.85 KB
/
server.js
File metadata and controls
76 lines (67 loc) · 1.85 KB
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
import babelify from "babelify";
import babel from "gulp-babel";
import browserify from "browserify";
import concat from "gulp-concat";
import connect from "gulp-connect";
import gulp from "gulp";
import buffer from "vinyl-buffer";
import livereload from "gulp-livereload";
import rename from "gulp-rename";
import sass from "gulp-sass";
import source from "vinyl-source-stream";
import streamify from "gulp-streamify";
import uglify from "gulp-uglify";
import watchify from "watchify";
// process.env.NODE_ENV = 'production' // used for building minify script
gulp.task("server", () => {
connect.server({
root: [__dirname, "build"],
port: 8001,
livereload: true,
});
});
gulp.task("sass", () => {
gulp
.src("./components/App.scss")
.pipe(sass())
.pipe(rename("app.css"))
.pipe(gulp.dest("./build/"))
.pipe(livereload());
});
var babelOptions = {
plugins: ["transform-object-assign"],
presets: ["es2015", "react", "stage-0"],
};
var customOpts = {
entries: "./components/App.jsx",
extensions: [".jsx"],
debug: true,
};
var opts = Object.assign({}, customOpts);
gulp.task("scripts", function () {
watchify(browserify(opts))
.transform("babelify", babelOptions)
.bundle()
.on("error", console.error.bind(console))
.pipe(source("app.js"))
.pipe(buffer())
.pipe(gulp.dest("./build/"))
.pipe(livereload());
});
gulp.task("buildjs", function () {
process.env.NODE_ENV = "production";
browserify(opts)
.transform("babelify", babelOptions)
.bundle()
.pipe(source("app.js"))
.pipe(buffer())
.pipe(uglify())
.pipe(gulp.dest("./build/"));
});
gulp.task("watch", () => {
livereload.listen();
gulp.watch(["components/*.scss"], ["sass"]);
gulp.watch(["components/*.jsx"], ["scripts"]);
});
gulp.task("dev", ["watch", "scripts", "sass", "server"]);
gulp.task("build", ["buildjs", "sass"]);