diff --git a/dist/server/config.js b/dist/server/config.js index 7f108488d202..6e040f40d98a 100644 --- a/dist/server/config.js +++ b/dist/server/config.js @@ -98,8 +98,16 @@ var logger = console; function addJsonLoaderIfNotAvailable(config) { var jsonLoaderExists = config.module.loaders.reduce(function (value, loader) { - return value || [].concat(loader.test).some(function (regex) { - return regex.test('my_package.json'); + return value || [].concat(loader.test).some(function (matcher) { + var isRegex = matcher instanceof RegExp; + var testString = 'my_package.json'; + if (isRegex) { + return matcher.test(testString); + } + if (typeof matcher === 'function') { + return matcher(testString); + } + return false; }); }, false); diff --git a/src/server/config.js b/src/server/config.js index 84cba3cd3d34..6cc8b126d4bb 100644 --- a/src/server/config.js +++ b/src/server/config.js @@ -11,7 +11,17 @@ const logger = console; export function addJsonLoaderIfNotAvailable(config) { const jsonLoaderExists = config.module.loaders.reduce( (value, loader) => { - return value || [].concat(loader.test).some(regex => regex.test('my_package.json')); + return value || [].concat(loader.test).some((matcher) => { + const isRegex = matcher instanceof RegExp; + const testString = 'my_package.json'; + if (isRegex) { + return matcher.test(testString); + } + if (typeof matcher === 'function') { + return matcher(testString); + } + return false; + }); }, false );