From 8c26472031d10400d829200fd6d65f0306ab442d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Chopin?= Date: Tue, 25 Aug 2020 14:03:09 +0200 Subject: [PATCH] fix: handle HMR for tailwind config Fixes #157 --- lib/module.js | 3 +++ package.json | 1 + yarn.lock | 17 ++++++++++++++++- 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/lib/module.js b/lib/module.js index 71adffd6..ccb253ec 100644 --- a/lib/module.js +++ b/lib/module.js @@ -1,6 +1,8 @@ const { join, resolve, relative } = require('path') const { pathExists } = require('fs-extra') const defu = require('defu') +const clearModule = require('clear-module') + const logger = require('./logger') const defaultTailwindConfig = require('./files/tailwind.config.js') @@ -27,6 +29,7 @@ module.exports = async function (moduleOptions) { // Get and extend the Tailwind config let tailwindConfig = {} if (await pathExists(configPath)) { + clearModule(configPath) tailwindConfig = require(configPath) logger.info(`Merging Tailwind config from ~/${relative(this.options.rootDir, configPath)}`) } diff --git a/package.json b/package.json index 4a8fb507..58c04850 100755 --- a/package.json +++ b/package.json @@ -24,6 +24,7 @@ "lib" ], "dependencies": { + "clear-module": "^4.1.1", "consola": "^2.15.0", "defu": "^3.1.0", "fs-extra": "^9.0.1", diff --git a/yarn.lock b/yarn.lock index 77aa283e..309a2080 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2976,7 +2976,7 @@ callsites@^2.0.0: resolved "https://registry.yarnpkg.com/callsites/-/callsites-2.0.0.tgz#06eb84f00eea413da86affefacbffb36093b3c50" integrity sha1-BuuE8A7qQT2oav/vrL/7Ngk7PFA= -callsites@^3.0.0: +callsites@^3.0.0, callsites@^3.1.0: version "3.1.0" resolved "https://registry.yarnpkg.com/callsites/-/callsites-3.1.0.tgz#b3630abd8943432f54b3f0519238e33cd7df2f73" integrity sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ== @@ -3234,6 +3234,14 @@ clean-stack@^2.0.0: resolved "https://registry.yarnpkg.com/clean-stack/-/clean-stack-2.2.0.tgz#ee8472dbb129e727b31e8a10a427dee9dfe4008b" integrity sha512-4diC9HaTE+KRAMWhDhrGOECgWZxoevMc5TlkObMqNSsVU62PYzXZ/SMTjzyGAFF1YusgxGcSWTEXBhp0CPwQ1A== +clear-module@^4.1.1: + version "4.1.1" + resolved "https://registry.yarnpkg.com/clear-module/-/clear-module-4.1.1.tgz#bf8ba3b62eb70ee1e0adec90589741425cf32db8" + integrity sha512-ng0E7LeODcT3QkazOckzZqbca+JByQy/Q2Z6qO24YsTp+pLxCfohGz2gJYJqZS0CWTX3LEUiHOqe5KlYeUbEMw== + dependencies: + parent-module "^2.0.0" + resolve-from "^5.0.0" + cli-boxes@^2.2.0: version "2.2.0" resolved "https://registry.yarnpkg.com/cli-boxes/-/cli-boxes-2.2.0.tgz#538ecae8f9c6ca508e3c3c95b453fe93cb4c168d" @@ -8212,6 +8220,13 @@ parent-module@^1.0.0: dependencies: callsites "^3.0.0" +parent-module@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/parent-module/-/parent-module-2.0.0.tgz#fa71f88ff1a50c27e15d8ff74e0e3a9523bf8708" + integrity sha512-uo0Z9JJeWzv8BG+tRcapBKNJ0dro9cLyczGzulS6EfeyAdeC9sbojtW6XwvYxJkEne9En+J2XEl4zyglVeIwFg== + dependencies: + callsites "^3.1.0" + parse-asn1@^5.0.0, parse-asn1@^5.1.5: version "5.1.5" resolved "https://registry.yarnpkg.com/parse-asn1/-/parse-asn1-5.1.5.tgz#003271343da58dc94cace494faef3d2147ecea0e"