I'm using craco for my create-react-app and I'm trying to import a javascript file from another directory, external to the app src.
I've heard it is possible but haven't found anything in their documentation about this, at least not from what I've seen.
My app is built using React version 17.0.2, in case it might help.
Any idea how to acheive this?
The solution for my question was to add this inside my craco.config.ts exported object:
https://github.com/facebook/create-react-app/issues/9127#issuecomment-646989707
You need to add this too in the root of the exported object(e.g: module.exports = { ...):
webpack: {
alias: {},
plugins: {
add: [], /* An array of plugins */
remove: [], /* An array of plugin constructor's names (i.e. "StyleLintPlugin", "ESLintWebpackPlugin" ) */
},
configure: webpackConfig => {
const scopePluginIndex = webpackConfig.resolve.plugins.findIndex(
({ constructor }) => constructor && constructor.name === 'ModuleScopePlugin'
);
webpackConfig.resolve.plugins.splice(scopePluginIndex, 1);
return webpackConfig;
}
},