Skip to content

Instantly share code, notes, and snippets.

@du5rte
Created Feb 25, 2019
Embed
What would you like to do?
Add support for lerna and/or yarn workspaces to react-scripts
// 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)
/*
{
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