Skip to content

Commit 7bfe232

Browse files
Jasper De Moordevongovett
authored andcommitted
support json comments (#171)
1 parent 2e32662 commit 7bfe232

3 files changed

Lines changed: 5 additions & 2 deletions

File tree

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
"posthtml": "^0.9.2",
3535
"resolve": "^1.4.0",
3636
"serve-static": "^1.12.4",
37+
"strip-json-comments": "^2.0.1",
3738
"uglify-js": "^3.0.28",
3839
"v8-compile-cache": "^1.1.0",
3940
"worker-farm": "^1.4.1",

src/utils/config.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
const fs = require('./fs');
22
const path = require('path');
33
const parseJson = require('parse-json');
4+
const stripJsonComments = require('strip-json-comments');
45

56
const existsCache = new Map();
67

@@ -35,7 +36,8 @@ async function load(filepath, filenames, root = path.parse(filepath).root) {
3536
return require(configFile);
3637
}
3738

38-
return parseJson(await fs.readFile(configFile));
39+
let configStream = await fs.readFile(configFile);
40+
return parseJson(stripJsonComments(configStream.toString()));
3941
}
4042

4143
return null;

yarn.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4728,7 +4728,7 @@ strip-indent@^2.0.0:
47284728
version "2.0.0"
47294729
resolved "https://registry.yarnpkg.com/strip-indent/-/strip-indent-2.0.0.tgz#5ef8db295d01e6ed6cbf7aab96998d7822527b68"
47304730

4731-
strip-json-comments@~2.0.1:
4731+
strip-json-comments@^2.0.1, strip-json-comments@~2.0.1:
47324732
version "2.0.1"
47334733
resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-2.0.1.tgz#3c531942e908c2697c0ec344858c286c7ca0a60a"
47344734

0 commit comments

Comments
 (0)