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

120
Visualizações
Grunt doesn't "require" JavaScript files from all folders in path when building the Destination file

I have a source with a lot of files and I'm generating a single file as the destination file , however when the file is generated it doesn't requires some js files that are located in path

The file that needs to be required is located at src/components/employees/index.js.

It's contents:

module.exports = { 
  IncludeMe: 'Some-Payload-Goes-Here......'
}

The main.js file:

const employeesData = require('src/components/employees')
const getEmployeeData = (... .... ....) => {
  try {     
   ...
   ...   // Data manipulations
   ...
   
   return { 
   
    ...employeesData
   };
  } catch (err) {
    return err;
  }
}

module.exports = getEmployeeData;

And this is the GruntFile

module.exports = (grunt) => {
    grunt.initConfig({
      'string-replace': {
        dist: {
          files: {
            'output/': [
              'src/**/*.js',
              'main.js',
              '!src/**/*.test.js',
              '!src/**/index.js',
            ],
          },
          options: {
            replacements: [{
              pattern: /module\.exports[\s]?=[\s]?([a-zA-Z0-9,\{\}\s]+)\;/ig,
              replacement: ''
            },
              {
                pattern: /const[\s]?([a-zA-Z0-9\{\}\s\,]+)[\s]?=[\s]?require\(([a-zA-Z0-9.\/\\\']+)\)\;/ig,
                replacement: ''
              }]
          }
        }
      },
      uglify: {
        prod: {
          files: { 'output/main.js': ['output/src/**/*.js', 'output/main.js'] },
          options: {
            report: true,
            preserveComments: false,
            compress: true,
            beautify: true
          },
        },
      },
      clean: ['output/src/', 'output/main.js']
    });
    grunt.loadNpmTasks('grunt-contrib-uglify');
    grunt.loadNpmTasks('grunt-string-replace');
    grunt.loadNpmTasks('grunt-contrib-clean');
    grunt.registerTask('default', ['string-replace', 'uglify', 'clean']);
  };
  

The generated file looks as follows:

   try {
        var u = {
            ...u = {},
            ...employeesData 
        };
        return Object.keys(u).length ? u : {};
    } catch (r) {
        
    }

Notice it doesn't put the contents of employeesData.

Any idea how to fix this ?

about 4 years ago · Juan Pablo Isaza
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