Open dstaley opened 4 years ago
This issue has been automatically marked as stale because it has not had any recent activity. It will be closed in 5 days if no further activity occurs.
I'm running into this issue. Has anyone discovered a solution?
For future reference, my issue was caused because CRA does not look through node_modules
in the current react-scripts webpack.config.js
file on the following loader:
// Process application JS with Babel.
// The preset includes JSX, Flow, TypeScript, and some ESnext features.
{
test: /\.(js|mjs|jsx|ts|tsx)$/,
include: paths.appSrc,
loader: require.resolve('babel-loader'),
options: {
customize: require.resolve(
'babel-preset-react-app/webpack-overrides'
),
You need to change include: paths.appSrc
to include: [paths.appSrc, paths.appNodeModules,]
.
You can do this without ejecting by using react-app-rewired, CRACO, or any other webpack extender for CRA using the following config:
const paths = require("./node_modules/react-scripts/config/paths");
module.exports = {
webpack: function (config, env) {
config.module.rules[1].oneOf[2].include = [
paths.appSrc,
paths.appNodeModules,
];
return config;
},
};
Hope this helps anyone who comes across a similar issue!
This issue has been automatically marked as stale because it has not had any recent activity. It will be closed in 5 days if no further activity occurs.
@dstaley did @CTLaChance's solution work for you? I'm trying it out and with some adjustments rules[1].oneOf[3]
I'm still getting a path for SVG files imported by npm modules.
Anyone have any further help here?
Describe the bug
Third-party npm modules that import SVGs in the following manner aren't transformed into React components:
Instead, they remain as URL imports to the SVG file.
Did you try recovering your dependencies?
Yes.
Which terms did you search for in User Guide?
SVG
Environment
Steps to reproduce
ReactComponent as
method.Expected behavior
The SVG renders.
Actual behavior
Reproducible demo
TBD
Additional Comments
I'm actually not sure if this is an intentional behavior or not. If it isn't intentional, and I should be able to import modules using this convention, please let me know and I'll put together a reproducible demo.