From 2dd9d5a27eec8a22f7f4e45ca55918f8eee60ff7 Mon Sep 17 00:00:00 2001 From: Colby Gutierrez-Kraybill Date: Wed, 18 Jul 2018 11:37:58 -0400 Subject: [PATCH 1/6] watchOptions required for use in docker environment MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This will work in both docker and outside of docker, and tunes the load on a docker container running webpack to not overly burden a local host’s cpu watching for changes. By default, webpack-dev-middleware is supposed to be watching, but in practice this seems to not be the case in docker containers, as fsevents are not passed through the NFS mount into a container and it requires explicit polling to enable watching for changes. --- dev-server/index.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/dev-server/index.js b/dev-server/index.js index 61874bd15..3386b621a 100644 --- a/dev-server/index.js +++ b/dev-server/index.js @@ -21,7 +21,15 @@ routes.forEach(route => { app.get(route.pattern, handler(route)); }); -app.use(webpackDevMiddleware(compiler)); +app.use(webpackDevMiddleware(compiler, + { + watchOptions: { + aggregateTimeout: 500, + poll: 2500, + ignored: ['node_modules','build'] + } + } +)); var proxyHost = process.env.FALLBACK || ''; if (proxyHost !== '') { From 1624c92ef4f15ff0881d7158a22d33dd9c243486 Mon Sep 17 00:00:00 2001 From: Colby Gutierrez-Kraybill Date: Wed, 18 Jul 2018 11:48:52 -0400 Subject: [PATCH 2/6] Add USE_DOCKER_WATCHOPTIONS Let docker containers to make use of watchOptions and polling --- docker-compose.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/docker-compose.yml b/docker-compose.yml index 8915d2b21..99af28a33 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -15,6 +15,7 @@ services: environment: - API_HOST=http://localhost:8491 - FALLBACK=http://localhost:8080 + - USE_DOCKER_WATCHOPTIONS=true build: context: ./ dockerfile: Dockerfile From a76e36054c07d28068e45c6536ec19f0555bbdcb Mon Sep 17 00:00:00 2001 From: Colby Gutierrez-Kraybill Date: Wed, 18 Jul 2018 11:49:52 -0400 Subject: [PATCH 3/6] Move watchOptions into middlewareOptions This creates middlewareOptions and a check on USE_DOCKER_WATCHOPTIONS as a pathway to have docker containers use polling for file system updates. --- dev-server/index.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/dev-server/index.js b/dev-server/index.js index 3386b621a..ee0f708c6 100644 --- a/dev-server/index.js +++ b/dev-server/index.js @@ -21,15 +21,18 @@ routes.forEach(route => { app.get(route.pattern, handler(route)); }); -app.use(webpackDevMiddleware(compiler, - { +var middlewareOptions = {}; +if (process.env.USE_DOCKER_WATCHOPTIONS) { + middlewareOptions = { watchOptions: { aggregateTimeout: 500, poll: 2500, ignored: ['node_modules','build'] } - } -)); + }; +} + +app.use(webpackDevMiddleware(compiler, middlewareOptions)); var proxyHost = process.env.FALLBACK || ''; if (proxyHost !== '') { From 19e141fc0e039e7cbf2094331519a2e375197dbf Mon Sep 17 00:00:00 2001 From: Colby Gutierrez-Kraybill Date: Wed, 18 Jul 2018 16:00:34 -0400 Subject: [PATCH 4/6] Fix linting issue with space after comma --- dev-server/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dev-server/index.js b/dev-server/index.js index ee0f708c6..5ab70abbd 100644 --- a/dev-server/index.js +++ b/dev-server/index.js @@ -27,7 +27,7 @@ if (process.env.USE_DOCKER_WATCHOPTIONS) { watchOptions: { aggregateTimeout: 500, poll: 2500, - ignored: ['node_modules','build'] + ignored: ['node_modules', 'build'] } }; } From cd8d951fd64fc85df7d49c34037b36811c2ceffb Mon Sep 17 00:00:00 2001 From: Colby Gutierrez-Kraybill Date: Wed, 18 Jul 2018 16:02:22 -0400 Subject: [PATCH 5/6] Linting tests will not work if scratch-gui is linked directly into local directory MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We’re currently linking scratch-gui directly into the scratch-www directory (either through a bind mount in docker) or a symoblic link in unix. This causes the current make lint target to fail when it attempts to look in that directory for lint targets. Also, don’t bother linting node_modules --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 6fed25bde..f47cacb35 100644 --- a/Makefile +++ b/Makefile @@ -55,7 +55,7 @@ test: @make tap lint: - $(ESLINT) . --ext .js,.jsx,.json + $(ESLINT) --ignore-pattern scratch-gui --ignore-pattern node_modules . --ext .js,.jsx,.json $(SASSLINT) ./src/*.scss $(SASSLINT) ./src/**/*.scss From 5bf674a440930cf02df5f87c857c12c5111d8ae5 Mon Sep 17 00:00:00 2001 From: Colby Gutierrez-Kraybill Date: Thu, 19 Jul 2018 08:48:44 -0400 Subject: [PATCH 6/6] Move the eslint ignore from Makefile lint rule to into .eslintignore --- .eslintignore | 1 + Makefile | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.eslintignore b/.eslintignore index 941eaa3fb..322608d70 100644 --- a/.eslintignore +++ b/.eslintignore @@ -5,3 +5,4 @@ intl/* locales/* **/*.min.js **/node_modules/* +scratch-gui/* diff --git a/Makefile b/Makefile index f47cacb35..6fed25bde 100644 --- a/Makefile +++ b/Makefile @@ -55,7 +55,7 @@ test: @make tap lint: - $(ESLINT) --ignore-pattern scratch-gui --ignore-pattern node_modules . --ext .js,.jsx,.json + $(ESLINT) . --ext .js,.jsx,.json $(SASSLINT) ./src/*.scss $(SASSLINT) ./src/**/*.scss