Error when trying to use grunt-contrib-uglify: “src files were empty”









up vote
4
down vote

favorite
1












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']);
;


Folder structure is as follows:



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


Important: I run grunt from the project folder.



When running grunt, there is a task before uglify:def which is responsible for generating src.js into project/out.



When I run grunt I can see src.js being generated into project/out, but when Grunt runs uglisy:def I get the following error:




Running "uglify:def" (uglify) task.



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



No files created.




What am i doing wrong?



Log



When running 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 */rn", 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.









share|improve this question























  • Running with the verbose flag grunt <task> --verbose is helpful when diagnosing things like this. What's the output when you run the task with the verbose flag?
    – steveax
    Jul 19 '15 at 17:13










  • Seems like it is missing the LHS of file mappings... strange.
    – Andry
    Jul 19 '15 at 18:04














up vote
4
down vote

favorite
1












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']);
;


Folder structure is as follows:



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


Important: I run grunt from the project folder.



When running grunt, there is a task before uglify:def which is responsible for generating src.js into project/out.



When I run grunt I can see src.js being generated into project/out, but when Grunt runs uglisy:def I get the following error:




Running "uglify:def" (uglify) task.



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



No files created.




What am i doing wrong?



Log



When running 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 */rn", 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.









share|improve this question























  • Running with the verbose flag grunt <task> --verbose is helpful when diagnosing things like this. What's the output when you run the task with the verbose flag?
    – steveax
    Jul 19 '15 at 17:13










  • Seems like it is missing the LHS of file mappings... strange.
    – Andry
    Jul 19 '15 at 18:04












up vote
4
down vote

favorite
1









up vote
4
down vote

favorite
1






1





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']);
;


Folder structure is as follows:



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


Important: I run grunt from the project folder.



When running grunt, there is a task before uglify:def which is responsible for generating src.js into project/out.



When I run grunt I can see src.js being generated into project/out, but when Grunt runs uglisy:def I get the following error:




Running "uglify:def" (uglify) task.



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



No files created.




What am i doing wrong?



Log



When running 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 */rn", 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.









share|improve this question















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']);
;


Folder structure is as follows:



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


Important: I run grunt from the project folder.



When running grunt, there is a task before uglify:def which is responsible for generating src.js into project/out.



When I run grunt I can see src.js being generated into project/out, but when Grunt runs uglisy:def I get the following error:




Running "uglify:def" (uglify) task.



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



No files created.




What am i doing wrong?



Log



When running 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 */rn", 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.






javascript gruntjs grunt-contrib-uglify






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jul 20 '15 at 19:33

























asked Jul 19 '15 at 16:32









Andry

6,5342089176




6,5342089176











  • Running with the verbose flag grunt <task> --verbose is helpful when diagnosing things like this. What's the output when you run the task with the verbose flag?
    – steveax
    Jul 19 '15 at 17:13










  • Seems like it is missing the LHS of file mappings... strange.
    – Andry
    Jul 19 '15 at 18:04
















  • Running with the verbose flag grunt <task> --verbose is helpful when diagnosing things like this. What's the output when you run the task with the verbose flag?
    – steveax
    Jul 19 '15 at 17:13










  • Seems like it is missing the LHS of file mappings... strange.
    – Andry
    Jul 19 '15 at 18:04















Running with the verbose flag grunt <task> --verbose is helpful when diagnosing things like this. What's the output when you run the task with the verbose flag?
– steveax
Jul 19 '15 at 17:13




Running with the verbose flag grunt <task> --verbose is helpful when diagnosing things like this. What's the output when you run the task with the verbose flag?
– steveax
Jul 19 '15 at 17:13












Seems like it is missing the LHS of file mappings... strange.
– Andry
Jul 19 '15 at 18:04




Seems like it is missing the LHS of file mappings... strange.
– Andry
Jul 19 '15 at 18:04












2 Answers
2






active

oldest

votes

















up vote
4
down vote



accepted










I've a configuration like the following, and it works fine for me.



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


,


Probably you confused the destination with the source. Try to switch them.






share|improve this answer




















  • Very stupid mistake, hard to spot when you work on something for too much time. thanks man!
    – Andry
    Jul 19 '15 at 20:39










  • Oh man, no problem!
    – Luca Colonnello
    Jul 19 '15 at 21:55

















up vote
0
down vote













It were happening due to, you are not registering above given tasks.



OK, lets start with concatenation in grunt:



concat: 
css:
src: ['./assets/css/*.css', './assets/css/**/*.css'],
dest: './dist/css/style.css'
,
js:
src: ['./assets/js/*.js', './assets/js/**/*.js'],
dest: './dist/js/script.js'

,


so, this concat is supposed to collect all css files from above given url / directories and concatenate to given destination in one place and so with js.



this will be simple concatenated style.css and script.js at dest destination directory.



but it won't work, till you not register this concat task inside below line:



grunt.registerTask('default', ['concat', 'cssmin', 'uglify']);


So, till concat will not concatenate those files in dest directory, how the uglify will collect and work!



Conclusion: task won't get execute till you not mention them inside grunt.registerTask function.






share|improve this answer




















    Your Answer






    StackExchange.ifUsing("editor", function ()
    StackExchange.using("externalEditor", function ()
    StackExchange.using("snippets", function ()
    StackExchange.snippets.init();
    );
    );
    , "code-snippets");

    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "1"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f31503397%2ferror-when-trying-to-use-grunt-contrib-uglify-src-files-were-empty%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    4
    down vote



    accepted










    I've a configuration like the following, and it works fine for me.



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


    ,


    Probably you confused the destination with the source. Try to switch them.






    share|improve this answer




















    • Very stupid mistake, hard to spot when you work on something for too much time. thanks man!
      – Andry
      Jul 19 '15 at 20:39










    • Oh man, no problem!
      – Luca Colonnello
      Jul 19 '15 at 21:55














    up vote
    4
    down vote



    accepted










    I've a configuration like the following, and it works fine for me.



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


    ,


    Probably you confused the destination with the source. Try to switch them.






    share|improve this answer




















    • Very stupid mistake, hard to spot when you work on something for too much time. thanks man!
      – Andry
      Jul 19 '15 at 20:39










    • Oh man, no problem!
      – Luca Colonnello
      Jul 19 '15 at 21:55












    up vote
    4
    down vote



    accepted







    up vote
    4
    down vote



    accepted






    I've a configuration like the following, and it works fine for me.



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


    ,


    Probably you confused the destination with the source. Try to switch them.






    share|improve this answer












    I've a configuration like the following, and it works fine for me.



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


    ,


    Probably you confused the destination with the source. Try to switch them.







    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Jul 19 '15 at 17:01









    Luca Colonnello

    912710




    912710











    • Very stupid mistake, hard to spot when you work on something for too much time. thanks man!
      – Andry
      Jul 19 '15 at 20:39










    • Oh man, no problem!
      – Luca Colonnello
      Jul 19 '15 at 21:55
















    • Very stupid mistake, hard to spot when you work on something for too much time. thanks man!
      – Andry
      Jul 19 '15 at 20:39










    • Oh man, no problem!
      – Luca Colonnello
      Jul 19 '15 at 21:55















    Very stupid mistake, hard to spot when you work on something for too much time. thanks man!
    – Andry
    Jul 19 '15 at 20:39




    Very stupid mistake, hard to spot when you work on something for too much time. thanks man!
    – Andry
    Jul 19 '15 at 20:39












    Oh man, no problem!
    – Luca Colonnello
    Jul 19 '15 at 21:55




    Oh man, no problem!
    – Luca Colonnello
    Jul 19 '15 at 21:55












    up vote
    0
    down vote













    It were happening due to, you are not registering above given tasks.



    OK, lets start with concatenation in grunt:



    concat: 
    css:
    src: ['./assets/css/*.css', './assets/css/**/*.css'],
    dest: './dist/css/style.css'
    ,
    js:
    src: ['./assets/js/*.js', './assets/js/**/*.js'],
    dest: './dist/js/script.js'

    ,


    so, this concat is supposed to collect all css files from above given url / directories and concatenate to given destination in one place and so with js.



    this will be simple concatenated style.css and script.js at dest destination directory.



    but it won't work, till you not register this concat task inside below line:



    grunt.registerTask('default', ['concat', 'cssmin', 'uglify']);


    So, till concat will not concatenate those files in dest directory, how the uglify will collect and work!



    Conclusion: task won't get execute till you not mention them inside grunt.registerTask function.






    share|improve this answer
























      up vote
      0
      down vote













      It were happening due to, you are not registering above given tasks.



      OK, lets start with concatenation in grunt:



      concat: 
      css:
      src: ['./assets/css/*.css', './assets/css/**/*.css'],
      dest: './dist/css/style.css'
      ,
      js:
      src: ['./assets/js/*.js', './assets/js/**/*.js'],
      dest: './dist/js/script.js'

      ,


      so, this concat is supposed to collect all css files from above given url / directories and concatenate to given destination in one place and so with js.



      this will be simple concatenated style.css and script.js at dest destination directory.



      but it won't work, till you not register this concat task inside below line:



      grunt.registerTask('default', ['concat', 'cssmin', 'uglify']);


      So, till concat will not concatenate those files in dest directory, how the uglify will collect and work!



      Conclusion: task won't get execute till you not mention them inside grunt.registerTask function.






      share|improve this answer






















        up vote
        0
        down vote










        up vote
        0
        down vote









        It were happening due to, you are not registering above given tasks.



        OK, lets start with concatenation in grunt:



        concat: 
        css:
        src: ['./assets/css/*.css', './assets/css/**/*.css'],
        dest: './dist/css/style.css'
        ,
        js:
        src: ['./assets/js/*.js', './assets/js/**/*.js'],
        dest: './dist/js/script.js'

        ,


        so, this concat is supposed to collect all css files from above given url / directories and concatenate to given destination in one place and so with js.



        this will be simple concatenated style.css and script.js at dest destination directory.



        but it won't work, till you not register this concat task inside below line:



        grunt.registerTask('default', ['concat', 'cssmin', 'uglify']);


        So, till concat will not concatenate those files in dest directory, how the uglify will collect and work!



        Conclusion: task won't get execute till you not mention them inside grunt.registerTask function.






        share|improve this answer












        It were happening due to, you are not registering above given tasks.



        OK, lets start with concatenation in grunt:



        concat: 
        css:
        src: ['./assets/css/*.css', './assets/css/**/*.css'],
        dest: './dist/css/style.css'
        ,
        js:
        src: ['./assets/js/*.js', './assets/js/**/*.js'],
        dest: './dist/js/script.js'

        ,


        so, this concat is supposed to collect all css files from above given url / directories and concatenate to given destination in one place and so with js.



        this will be simple concatenated style.css and script.js at dest destination directory.



        but it won't work, till you not register this concat task inside below line:



        grunt.registerTask('default', ['concat', 'cssmin', 'uglify']);


        So, till concat will not concatenate those files in dest directory, how the uglify will collect and work!



        Conclusion: task won't get execute till you not mention them inside grunt.registerTask function.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 10 at 3:50









        ArifMustafa

        1,33821629




        1,33821629



























            draft saved

            draft discarded
















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.





            Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


            Please pay close attention to the following guidance:


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f31503397%2ferror-when-trying-to-use-grunt-contrib-uglify-src-files-were-empty%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            How to how show current date and time by default on contact form 7 in WordPress without taking input from user in datetimepicker

            Syphilis

            Darth Vader #20