Skip to content

Commit

Permalink
fix: handle HMR for tailwind config
Browse files Browse the repository at this point in the history
Fixes #157
  • Loading branch information
Atinux committed Aug 25, 2020
1 parent d6cb9ad commit 8c26472
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
3 changes: 3 additions & 0 deletions lib/module.js
Original file line number Diff line number Diff line change
@@ -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')

Expand All @@ -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)}`)
}
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"lib"
],
"dependencies": {
"clear-module": "^4.1.1",
"consola": "^2.15.0",
"defu": "^3.1.0",
"fs-extra": "^9.0.1",
Expand Down
17 changes: 16 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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==
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down

0 comments on commit 8c26472

Please sign in to comment.