Created
February 25, 2019 14:23
-
-
Save du5rte/0670f84f8c0c53dd530355f08c52f169 to your computer and use it in GitHub Desktop.
Add support for lerna and/or yarn workspaces to react-scripts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// HACK: | |
// https://github.com/facebook/create-react-app/issues/1333#issuecomment-347970625 | |
module.exports.appLernaModules = [] | |
function searchModules(dir) { | |
fs.readdirSync(dir).forEach(folderName => { | |
if (folderName === 'react-scripts') return | |
if (folderName[0] === '.') return | |
const baseDir = path.resolve(dir) | |
const fullDir = path.join(baseDir, folderName) | |
if (folderName[0] === '@') { | |
return searchModules(fullDir) | |
} | |
try { | |
if (fs.lstatSync(fullDir).isSymbolicLink()) { | |
module.exports.appLernaModules.push(fs.realpathSync(fullDir)) | |
} | |
} catch (error) { | |
} | |
}) | |
} | |
searchModules(module.exports.appNodeModules) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
{ | |
test: /\.(js|mjs|jsx|ts|tsx)$/, | |
include: paths.appSrc, | |
loader: require.resolve('babel-loader'), | |
*/ include: paths.appLernaModules.concat(paths.appSrc), | |
/* options: { | |
customize: require.resolve( | |
'babel-preset-react-app/webpack-overrides' | |
), | |
... | |
plugins: [ | |
[ | |
require.resolve('babel-plugin-named-asset-import'), | |
*/ require.resolve('babel-plugin-react-native-web'), | |
/* { | |
loaderMap: { | |
svg: { | |
ReactComponent: | |
'@svgr/webpack?-prettier,-svgo![path]', | |
}, | |
}, | |
}, | |
], | |
], | |
} | |
*/ | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment