From 2f3de1fa1ea0c4f27d75f69b3c7d755833f8b75f Mon Sep 17 00:00:00 2001 From: Miodec Date: Mon, 7 Feb 2022 18:35:09 +0100 Subject: [PATCH] reworked build process deploying from /public no longer copying files to dist/gen --- .gitignore | 1 + firebase.json | 2 +- gulpfile.js | 55 +++++++++------------------------------------------ 3 files changed, 11 insertions(+), 47 deletions(-) diff --git a/.gitignore b/.gitignore index 09ccabce0..5fea8afa2 100644 --- a/.gitignore +++ b/.gitignore @@ -80,6 +80,7 @@ serviceAccountKey*.json #generated files dist/ +public/ #cloudflare y .cloudflareKey.txt diff --git a/firebase.json b/firebase.json index 9bd8e0519..3c2f6aace 100644 --- a/firebase.json +++ b/firebase.json @@ -1,6 +1,6 @@ { "hosting": { - "public": "dist", + "public": "public", "ignore": ["firebase.json", "**/.*", "**/node_modules/**"], "rewrites": [ { diff --git a/gulpfile.js b/gulpfile.js index dcd63460a..9ef4f2f24 100644 --- a/gulpfile.js +++ b/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"));