Skip to content

Commit

Permalink
Use babel-loader from react-scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
mrmckeb committed Mar 31, 2019
1 parent e7cddc0 commit d782da6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
3 changes: 3 additions & 0 deletions app/react/src/server/cra-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,5 +176,8 @@ export function applyCRAWebpackConfig(baseConfig, configDir) {
...baseConfig.resolve,
extensions: [...baseConfig.resolve.extensions, ...tsExtensions],
},
resolveLoader: {
modules: ['node_modules', path.join(getReactScriptsPath(), 'node_modules')],
},
};
}
6 changes: 5 additions & 1 deletion lib/cli/generators/REACT_SCRIPTS/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import mergeDirs from 'merge-dirs';
import path from 'path';
import fs from 'fs';
import semver from 'semver';
import { getVersions, getPackageJson, writePackageJson, installBabel } from '../../lib/helpers';

export default async npmOptions => {
Expand All @@ -24,7 +25,10 @@ export default async npmOptions => {
packageJson.devDependencies['@storybook/addon-links'] = linksVersion;
packageJson.devDependencies['@storybook/addons'] = addonsVersion;

await installBabel(npmOptions, packageJson);
// When working with `create-react-app@>=2.0.0`, we know `babel-loader` is installed.
if (semver.lt(packageJson.dependencies['react-scripts'], '2.0.0')) {
await installBabel(npmOptions, packageJson);
}

packageJson.scripts.storybook = 'start-storybook -p 9009';
packageJson.scripts['build-storybook'] = 'build-storybook';
Expand Down

0 comments on commit d782da6

Please sign in to comment.