From b20f5d745b859e3f5373977b107c0dc0ce3f015e Mon Sep 17 00:00:00 2001 From: Daniel Date: Thu, 13 Apr 2017 22:47:10 +0200 Subject: [PATCH 1/3] feat(hot-reload): delete require-cache on reload --- index.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index ddd61a9..5a50034 100644 --- a/index.js +++ b/index.js @@ -3,6 +3,7 @@ const loaderUtils = require('loader-utils'); const fs = require('fs'); const convert = require('./convert'); +const path = require('path'); const loader = function(content) { @@ -16,12 +17,12 @@ const loader = function(content) config.files = [config.files]; } config.files.forEach((path) => { - path = path.replace(/["']/g, ''); - this.addDependency(path); if (path.endsWith('.json')) { Object.assign(vars, JSON.parse(fs.readFileSync(path, 'utf8'))); } if (path.endsWith('.js')) { + const resolvedFilePath = path.resolve(path.replace(/["']/g, '')); + delete require.cache[resolvedFilePath]; Object.assign(vars, require(path)); } }) From 2b6d44d1ac962081592873e0a9ff8e4dd417e157 Mon Sep 17 00:00:00 2001 From: Daniel Date: Thu, 13 Apr 2017 22:47:58 +0200 Subject: [PATCH 2/3] style(*): add missing semi-colon --- convert.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/convert.js b/convert.js index 17fd39a..81075c2 100644 --- a/convert.js +++ b/convert.js @@ -34,7 +34,7 @@ function formatValue(value) { prefix: '', suffix: ',', suffixLastItem: false, - } + }; return '(\n' + objToValue(value, opts) + '\n)'; } From 31c3d9661782a84b80f148c781dcdca9215a746b Mon Sep 17 00:00:00 2001 From: Daniel Date: Thu, 13 Apr 2017 22:49:12 +0200 Subject: [PATCH 3/3] chore(npm): bump version to v1.2.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index c1948ef..a5b7ec3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@epegzz/sass-vars-loader", - "version": "1.1.0", + "version": "1.2.0", "author": "Daniel Schäfer ", "description": "A SASS vars loader for Webpack. Load global SASS vars from JS/JSON files or from Webpack config.", "files": [