Error while trying to use grunt-contrib-uglify: "src files were empty"

I have the following Gruntfile.js

:

module.exports = function(grunt) {
  var config = {
    pkg: grunt.file.readJSON('package.json'),

    /* Some other tasks... */

    uglify: {
      options: {
        banner: '/*! <%= pkg.name %> <%= grunt.template.today("yyyy-mm-dd") %> */\n'
      },
      def: {
        files: {
          'out/src.js': 'out/src.min.js'
        }
      }
    }
  };

  grunt.initConfig(config);
  grunt.loadNpmTasks('grunt-contrib-uglify');

  grunt.registerTask('default', [/* <other-tasks>, */ 'uglify:def']);
};

      

The folder structure looks like this:

project
  |
  +-out (folder)
  +-Gruntfile.js

      

Important: I run grunt

from a folderproject

.

At startup grunt

, uglify:def

a task arises in front of it that is responsible for generating src.js

the project/out

.

When I run grunt

I see the src.js

generated in project/out

, but when Grunt starts uglisy:def

I get the following error:

Run the "uglify: def" (uglify) task.

Destination out / src.js is not written because the src files were empty.

No files created.

What am I doing wrong?

Magazine

When working with, --verbose

I get:

Running "uglify:def" (uglify) task
Verifying property uglify.def exists in config...OK
Files: [no src] -> out/src.js
Options: banner="/*! My Pack 2015-07-19 */\r\n", footer="", compress={"warnings":false}, mangle={}, beautify=false, report="
min", expression=false, maxLineLen=32000, ASCIIOnly=false, screwIE8=false, quoteStyle=0
>> Destination out/src.js not written because src files were empty.
>> No files created.

      

+3


source to share


1 answer


I have a configuration like the following and it works great for me.

    // uglify javascript
    uglify: {
        dev: {
            options: {
                mangle: true
            },
            files: {
                'js/dest.min.js': 'js/source.js'
            }
        }
    },

      



You are probably confusing target with source. Try switching them.

+4


source







All Articles