From 90d2c3b3441cb548af2f41d2cfbce1ef665b47a0 Mon Sep 17 00:00:00 2001 From: Oliver Eyton-Williams Date: Sun, 30 May 2021 09:59:55 +0200 Subject: [PATCH] feat: use webpack caching in development (#42286) * feat: use webpack caching in development This cuts build time for build-workers considerably. * fix: update gitpod config Co-authored-by: Shaun Hamilton --- .gitpod.yml | 3 +-- client/package.json | 7 +++---- client/webpack-workers.js | 1 + 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/.gitpod.yml b/.gitpod.yml index 29a3f10b2b..630f963098 100644 --- a/.gitpod.yml +++ b/.gitpod.yml @@ -51,8 +51,7 @@ tasks: init: > cd ./client && gp sync-await npm-ci && - npm run prebuild && - npm run build:workers && + npm run predevelop && cd .. command: > gp await-port 3000 && diff --git a/client/package.json b/client/package.json index 645636d1f6..3de0fc020f 100644 --- a/client/package.json +++ b/client/package.json @@ -19,12 +19,11 @@ "author": "freeCodeCamp ", "main": "none", "scripts": { - "prebuild": "echo 'Client workers building...' && npm run build:workers && echo 'Client workers ready.' && node ../tools/scripts/build/ensure-env.js", + "prebuild": "node ../tools/scripts/build/ensure-env.js && npm run build:workers -- --env production", "build": "node --max_old_space_size=7168 node_modules/gatsby-cli build --prefix-paths", - "build:workers": "node --max_old_space_size=7168 node_modules/webpack-cli/bin/cli --env production --config ./webpack-workers.js && echo", - "build:workers:debug": "node --max_old_space_size=7168 node_modules/webpack-cli/bin/cli --env production --config ./webpack-workers.js --progress", + "build:workers": "node --max_old_space_size=7168 node_modules/webpack-cli/bin/cli --config ./webpack-workers.js", "clean": "gatsby clean", - "predevelop": "npm run prebuild", + "predevelop": "node ../tools/scripts/build/ensure-env.js && npm run build:workers -- --env development", "develop": "gatsby develop --inspect=9230", "format": "npm run format:gatsby && npm run format:src && npm run format:utils", "format:gatsby": "prettier-eslint --write --trailing-comma none --single-quote './gatsby-*.js'", diff --git a/client/webpack-workers.js b/client/webpack-workers.js index 735a635b09..6dbd8b585d 100644 --- a/client/webpack-workers.js +++ b/client/webpack-workers.js @@ -8,6 +8,7 @@ module.exports = (env = {}) => { const staticPath = path.join(__dirname, './static/js'); const configPath = path.join(__dirname, '../config/client'); return { + cache: __DEV__ ? { type: 'filesystem' } : false, mode: __DEV__ ? 'development' : 'production', entry: { 'frame-runner': './src/client/frame-runner.js',