Skip to content

Commit

Permalink
Merge pull request #12 from epegzz/feat/hot-reload
Browse files Browse the repository at this point in the history
Feat/hot reload
  • Loading branch information
dsc8x authored Apr 13, 2017
2 parents 05d9970 + 31c3d96 commit 090801a
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion convert.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ function formatValue(value) {
prefix: '',
suffix: ',',
suffixLastItem: false,
}
};
return '(\n' + objToValue(value, opts) + '\n)';
}

Expand Down
5 changes: 3 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand All @@ -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));
}
})
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@epegzz/sass-vars-loader",
"version": "1.1.0",
"version": "1.2.0",
"author": "Daniel Schäfer <epegzz@gmail.com>",
"description": "A SASS vars loader for Webpack. Load global SASS vars from JS/JSON files or from Webpack config.",
"files": [
Expand Down

0 comments on commit 090801a

Please sign in to comment.