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

119
Views
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
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!