Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

283
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda