Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

278
Views
How to use a js file from outside of create-react-app directory, with craco?

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?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

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;
        }
    },
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!