mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2025-02-01 19:38:24 +08:00
reworked build process
deploying from /public no longer copying files to dist/gen
This commit is contained in:
parent
7e7fefbb0c
commit
2f3de1fa1e
3 changed files with 11 additions and 47 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -80,6 +80,7 @@ serviceAccountKey*.json
|
|||
|
||||
#generated files
|
||||
dist/
|
||||
public/
|
||||
|
||||
#cloudflare y
|
||||
.cloudflareKey.txt
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"hosting": {
|
||||
"public": "dist",
|
||||
"public": "public",
|
||||
"ignore": ["firebase.json", "**/.*", "**/node_modules/**"],
|
||||
"rewrites": [
|
||||
{
|
||||
|
|
55
gulpfile.js
55
gulpfile.js
|
@ -17,49 +17,20 @@ const through2 = require("through2");
|
|||
let eslintConfig = ".eslintrc.json";
|
||||
|
||||
task("clean", function () {
|
||||
return src("./dist/", { allowEmpty: true }).pipe(vinylPaths(del));
|
||||
return src(["./public/"], { allowEmpty: true }).pipe(vinylPaths(del));
|
||||
});
|
||||
|
||||
task("lint", function () {
|
||||
let filelist = [
|
||||
"./src/js/**/*.js",
|
||||
"!./src/js/global-dependencies.js",
|
||||
"!./src/js/exports.js",
|
||||
];
|
||||
filelist.push("./static/**/*.json");
|
||||
let filelist = ["./src/js/**/*.js", "./static/**/*.json"];
|
||||
return src(filelist)
|
||||
.pipe(eslint(eslintConfig))
|
||||
.pipe(eslint.format())
|
||||
.pipe(eslint.failAfterError());
|
||||
});
|
||||
|
||||
//concatenates and lints legacy js files and writes the output to dist/gen/index.js
|
||||
task("cat", function () {
|
||||
return src(["./src/js/global-dependencies.js", "./src/js/exports.js"])
|
||||
.pipe(concat("index.js"))
|
||||
.pipe(eslint(eslintConfig))
|
||||
.pipe(eslint.format())
|
||||
.pipe(eslint.failAfterError())
|
||||
.pipe(dest("./dist/gen"));
|
||||
});
|
||||
|
||||
task("copy-modules", function () {
|
||||
return src(
|
||||
[
|
||||
"./src/js/**/*.js",
|
||||
"!./src/js/global-dependencies.js",
|
||||
"!./src/js/exports.js",
|
||||
],
|
||||
{ allowEmpty: true, base: "./src/js" }
|
||||
).pipe(dest("./dist/gen"));
|
||||
});
|
||||
|
||||
//bundles the refactored js files together with index.js (the concatenated legacy js files)
|
||||
//it's odd that the entry point is generated, so we should seek a better way of doing this
|
||||
task("browserify", function () {
|
||||
const b = browserify({
|
||||
//index.js is generated by task "cat"
|
||||
entries: "./dist/gen/index.js",
|
||||
entries: "./src/js/index.js",
|
||||
//a source map isn't very useful right now because
|
||||
//the source files are concatenated together
|
||||
debug: false,
|
||||
|
@ -79,18 +50,18 @@ task("browserify", function () {
|
|||
mangle: false,
|
||||
})
|
||||
)
|
||||
.pipe(dest("./dist/js"));
|
||||
.pipe(dest("./public/js"));
|
||||
});
|
||||
|
||||
task("static", function () {
|
||||
return src("./static/**/*", { dot: true }).pipe(dest("./dist/"));
|
||||
return src("./static/**/*", { dot: true }).pipe(dest("./public/"));
|
||||
});
|
||||
|
||||
task("sass", function () {
|
||||
return src("./src/sass/*.scss")
|
||||
.pipe(concat("style.scss"))
|
||||
.pipe(sass({ outputStyle: "compressed" }).on("error", sass.logError))
|
||||
.pipe(dest("dist/css"));
|
||||
.pipe(dest("public/css"));
|
||||
});
|
||||
|
||||
task("updateSwCacheName", function () {
|
||||
|
@ -122,24 +93,16 @@ task("updateSwCacheName", function () {
|
|||
cb(null, file);
|
||||
})
|
||||
)
|
||||
.pipe(dest("./dist/"));
|
||||
.pipe(dest("./public/"));
|
||||
});
|
||||
|
||||
task(
|
||||
"compile",
|
||||
series(
|
||||
"lint",
|
||||
"cat",
|
||||
"copy-modules",
|
||||
"browserify",
|
||||
"static",
|
||||
"sass",
|
||||
"updateSwCacheName"
|
||||
)
|
||||
series("lint", "browserify", "static", "sass", "updateSwCacheName")
|
||||
);
|
||||
|
||||
task("watch", function () {
|
||||
watch(["./static/**/*", "./src/**/*"], series("compile"));
|
||||
watch(["./static/**/*", "./src/**/*", "gulpfile.js"], series("compile"));
|
||||
});
|
||||
|
||||
task("build", series("clean", "compile"));
|
||||
|
|
Loading…
Reference in a new issue