diff options
author | Bruce Berrios <[email protected]> | 2022-03-17 16:00:20 -0400 |
---|---|---|
committer | GitHub <[email protected]> | 2022-03-17 21:00:20 +0100 |
commit | 0fe99e0a28a63a144f95e8c1eca0211488520bf2 (patch) | |
tree | 729778503e4794f5ccc3b8eddcd08537c070527c /frontend/gulpfile.js | |
parent | 817287e59c72210349fcefa02dbe07a7fb8afb04 (diff) | |
download | monkeytype-0fe99e0a28a63a144f95e8c1eca0211488520bf2.tar.gz monkeytype-0fe99e0a28a63a144f95e8c1eca0211488520bf2.zip |
Handle static assets with webpack (#2723) bruception
* Move some static file management to webpack
* Add build time feedback
* Add lint step back
* Use concurrently
Diffstat (limited to 'frontend/gulpfile.js')
-rw-r--r-- | frontend/gulpfile.js | 59 |
1 files changed, 25 insertions, 34 deletions
diff --git a/frontend/gulpfile.js b/frontend/gulpfile.js index e3751fecb..3892e4005 100644 --- a/frontend/gulpfile.js +++ b/frontend/gulpfile.js @@ -8,7 +8,7 @@ const { task, src, dest, series, watch } = require("gulp"); const webpackDevConfig = require("./webpack/config.dev.js"); const webpackProdConfig = require("./webpack/config.prod.js"); -const JSONValidation = require("./json-validation"); +const JSONValidation = require("./scripts/json-validation"); const eslintConfig = "../.eslintrc.json"; task("clean", function () { @@ -33,37 +33,29 @@ task("validate-json-schema", function () { return JSONValidation.validateAll(); }); -task("webpack", async function () { - return new Promise((resolve, reject) => { - webpack(webpackDevConfig, (err, stats) => { - if (err) { - return reject(err); - } - if (stats.hasErrors()) { - return reject(new Error(stats.compilation.errors.join("\n"))); - } - resolve(); +const taskWithWebpackConfig = (webpackConfig) => { + return async () => { + return new Promise((resolve, reject) => { + webpack(webpackConfig, (err, stats) => { + if (err) { + return reject(err); + } + if (stats.hasErrors()) { + return reject(new Error(stats.compilation.errors.join("\n"))); + } + console.log( + `Finished building in ${ + (stats.endTime - stats.startTime) / 1000 + } second(s)` + ); + resolve(); + }); }); - }); -}); + }; +}; -task("webpack-production", async function () { - return new Promise((resolve, reject) => { - webpack(webpackProdConfig, (err, stats) => { - if (err) { - return reject(err); - } - if (stats.hasErrors()) { - return reject(new Error(stats.compilation.errors.join("\n"))); - } - resolve(); - }); - }); -}); - -task("static", function () { - return src("./static/**/*", { dot: true }).pipe(dest("./public/")); -}); +task("webpack", taskWithWebpackConfig(webpackDevConfig)); +task("webpack-production", taskWithWebpackConfig(webpackProdConfig)); task("sass", function () { return src("./src/styles/*.scss") @@ -72,7 +64,7 @@ task("sass", function () { .pipe(dest("public/css")); }); -task("compile", series("lint", "lint-json", "webpack", "static", "sass")); +task("compile", series("lint", "lint-json", "webpack", "sass")); task( "compile-production", @@ -81,7 +73,6 @@ task( "lint-json", "validate-json-schema", "webpack-production", - "static", "sass" ) ); @@ -95,9 +86,9 @@ task("watch", function () { "./src/scripts/*.js", "./src/scripts/*.ts", ], - series("lint", "webpack") + series("lint") ); - watch(["./static/**/*.*", "./static/*.*"], series("lint-json", "static")); + watch(["./static/**/*.*", "./static/*.*"], series("lint-json")); }); task("build", series("clean", "compile")); |