From 293cf0f78d0a009d17fd6f5933920f1b43087daa Mon Sep 17 00:00:00 2001 From: mkucmus Date: Mon, 8 Feb 2021 11:19:00 +0100 Subject: [PATCH] feat(nuxt-module): add CHOKIDAR_USEPOLLING flag for development (#1322) --- packages/cli/src/extensions/nuxt-extension.ts | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/packages/cli/src/extensions/nuxt-extension.ts b/packages/cli/src/extensions/nuxt-extension.ts index d0a425fed..5f41547dc 100644 --- a/packages/cli/src/extensions/nuxt-extension.ts +++ b/packages/cli/src/extensions/nuxt-extension.ts @@ -221,6 +221,28 @@ module.exports = (toolbox: GluegunToolbox) => { await toolbox.patching.append(".gitignore", "/static"); } + // Add chokidar flag + const configChokidarFlag = await toolbox.patching.exists( + "nuxt.config.js", + `CHOKIDAR_USEPOLLING` + ); + if (!configChokidarFlag) { + const configEnvSection = await toolbox.patching.exists( + "nuxt.config.js", + "env:" + ); + await toolbox.patching.patch("nuxt.config.js", { + insert: !configEnvSection + ? ` + env: { + CHOKIDAR_USEPOLLING: process.env.NODE_ENV == "production" ? 0 : 1, + },` + : ` + CHOKIDAR_USEPOLLING: process.env.NODE_ENV == "production" ? 0 : 1,`, + after: !configEnvSection ? "export default {" : "env: {", + }); + } + // Add telemetry flag const configTelemetryFlag = await toolbox.patching.exists( "nuxt.config.js",