Skip to content

Commit

Permalink
Merge pull request #98 from namuol/allow-comments-in-babelrc
Browse files Browse the repository at this point in the history
Use cjson for .babelrc parsing
  • Loading branch information
Muhammed Thanish committed Apr 12, 2016
2 parents 0ff689d + 85201ba commit db8661a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
8 changes: 6 additions & 2 deletions dist/server/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ exports.default = function (baseConfig, configDir) {
// if user has a .babelrc file in current directory
// use that to extend webpack configurations
if (_fs2.default.existsSync('./.babelrc')) {
var content = _fs2.default.readFileSync('./.babelrc');
var content = _fs2.default.readFileSync('./.babelrc', 'utf-8');
try {
var babelrc = JSON.parse(content);
var babelrc = _cjson2.default.parse(content);
config.module.loaders[0].query = babelrc;
} catch (e) {
logger.error('=> Error parsing .babelrc file: ' + e.message);
Expand Down Expand Up @@ -65,6 +65,10 @@ var _path = require('path');

var _path2 = _interopRequireDefault(_path);

var _cjson = require('cjson');

var _cjson2 = _interopRequireDefault(_cjson);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

// avoid ESLint errors
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"babel-preset-react": "^6.3.13",
"babel-preset-stage-2": "^6.3.13",
"babel-runtime": "^6.3.14",
"cjson": "^0.4.0",
"commander": "^2.9.0",
"expect": "^1.6.0",
"express": "^4.13.3",
Expand Down
5 changes: 3 additions & 2 deletions src/server/config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import fs from 'fs';
import path from 'path';
import cjson from 'cjson';

// avoid ESLint errors
const logger = console;
Expand All @@ -13,9 +14,9 @@ export default function (baseConfig, configDir) {
// if user has a .babelrc file in current directory
// use that to extend webpack configurations
if (fs.existsSync('./.babelrc')) {
const content = fs.readFileSync('./.babelrc');
const content = fs.readFileSync('./.babelrc', 'utf-8');
try {
const babelrc = JSON.parse(content);
const babelrc = cjson.parse(content);
config.module.loaders[0].query = babelrc;
} catch (e) {
logger.error(`=> Error parsing .babelrc file: ${e.message}`);
Expand Down

0 comments on commit db8661a

Please sign in to comment.