Skip to content

Commit

Permalink
Fix babel extends issue by replacing with absolute paths
Browse files Browse the repository at this point in the history
  • Loading branch information
stefvhuynh committed May 10, 2016
1 parent 45b41bf commit a365743
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 20 deletions.
22 changes: 11 additions & 11 deletions dist/manager.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/manager.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 15 additions & 3 deletions dist/server/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,22 @@ var _extends3 = _interopRequireDefault(_extends2);
exports.default = function (configType, baseConfig, configDir) {
var config = baseConfig;

// search for a .babelrc in the config directory, then the module root directory
// if found, use that to extend webpack configurations
var babelConfig = loadBabelConfig(_path2.default.resolve(configDir, '.babelrc')) || loadBabelConfig('.babelrc');
// Search for a .babelrc in the config directory, then the module root
// directory. If found, use that to extend webpack configurations.
var babelConfig = loadBabelConfig(_path2.default.resolve(configDir, '.babelrc'));
var inConfigDir = true;

if (!babelConfig) {
babelConfig = loadBabelConfig('.babelrc');
inConfigDir = false;
}

if (babelConfig) {
// If the custom config uses babel's `extends` clause, then replace it with
// an absolute path. `extends` will not work unless we do this.
if (babelConfig.extends) {
babelConfig.extends = inConfigDir ? _path2.default.resolve(configDir, babelConfig.extends) : _path2.default.resolve(babelConfig.extends);
}
config.module.loaders[0].query = babelConfig;
}

Expand Down
22 changes: 17 additions & 5 deletions src/server/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,24 @@ function loadBabelConfig(babelConfigPath) {
export default function (configType, baseConfig, configDir) {
const config = baseConfig;

// search for a .babelrc in the config directory, then the module root directory
// if found, use that to extend webpack configurations
const babelConfig =
loadBabelConfig(path.resolve(configDir, '.babelrc')) ||
loadBabelConfig('.babelrc');
// Search for a .babelrc in the config directory, then the module root
// directory. If found, use that to extend webpack configurations.
let babelConfig = loadBabelConfig(path.resolve(configDir, '.babelrc'));
let inConfigDir = true;

if (!babelConfig) {
babelConfig = loadBabelConfig('.babelrc');
inConfigDir = false;
}

if (babelConfig) {
// If the custom config uses babel's `extends` clause, then replace it with
// an absolute path. `extends` will not work unless we do this.
if (babelConfig.extends) {
babelConfig.extends = inConfigDir ?
path.resolve(configDir, babelConfig.extends) :
path.resolve(babelConfig.extends);
}
config.module.loaders[0].query = babelConfig;
}

Expand Down

0 comments on commit a365743

Please sign in to comment.