Ismael Moral
Ismael Moral

Reputation: 732

Gruntfile task is not running properly

When I run grunt command on my terminal, the concat taks doesn't create the concat/form.js, and I need it to minify the javascript code.

I have the next directory structure:

src/entry/form.js src/form/simple-form.js

This is my Gruntfile.js ,

Is anything wrong with that?

module.exports = function(grunt){

  grunt.initConfig({
    pkg: grunt.file.readJSON('package.json'),
    concat: {
      form: {
        options: {
          separator: ''
        },
        dist: {
          src: ['./src/**/*.js'],
          dest: './concat/form.js'
        }
      }
    },
    uglify:{
      form:{
        options: {
          sourceMap: true,
          souceMapIncludeSources: true
        },
        dist: {
          files: {
            'dist/test.min.js' : ['concat/form.js']
          }
        }
      }
    }
  });

  grunt.loadNpmTasks('grunt-contrib-concat');
  grunt.loadNpmTasks('grunt-contrib-uglify');
  grunt.registerTask('default', ['concat:form', 'uglify:form']);
};

Final Gruntfile.js

module.exports = function(grunt){

  grunt.initConfig({
    pkg: grunt.file.readJSON('package.json'),
    concat: {
      options: {
        separator: ''
      },
      form: {
        src: ['./src/**/*.js'],
        dest: './concat/form.js'
      }
    },
    uglify:{
      options: {
        sourceMap: true,
        souceMapIncludeSources: true
      },
      form: {
        files: {
          'dist/test.min.js' : ['concat/form.js']
        }
      }
    }
  });

  grunt.loadNpmTasks('grunt-contrib-concat');
  grunt.loadNpmTasks('grunt-contrib-uglify');
  grunt.registerTask('default', ['concat', 'uglify']);
};

Upvotes: 1

Views: 146

Answers (1)

smnbbrv
smnbbrv

Reputation: 24581

You use form and dist in the same time when probably it is a mistake. You should reduce this

concat: {
  form: {
    options: {
      separator: ''
    },
    dist: {
      src: ['./src/**/*.js'],
      dest: './concat/form.js'
    }
  }
},

to this

concat: {
  options: {
    separator: ''
  },
  form: {
    src: ['./src/**/*.js'],
    dest: './concat/form.js'
  }
},

See the examples how it should be done here

Upvotes: 1

Related Questions