{"id":2850,"date":"2014-02-25T06:58:26","date_gmt":"2014-02-25T06:58:26","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/02\/25\/grunt-uglify-task-failing-collection-of-common-programming-errors\/"},"modified":"2014-02-25T06:58:26","modified_gmt":"2014-02-25T06:58:26","slug":"grunt-uglify-task-failing-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/02\/25\/grunt-uglify-task-failing-collection-of-common-programming-errors\/","title":{"rendered":"grunt uglify task failing-Collection of common programming errors"},"content":{"rendered":"<p>I know this is marked as solved, but I still prefer this answer from a similar question because you can easily use the files again for another command without writing them twice.<\/p>\n<p>Basically, the answer says<\/p>\n<pre><code>\/\/Does not work\nsrc: ['client\/src\/js\/*.js'],\ndest: ['client\/dist\/js\/build.js']\n\/\/Works\nsrc: ['client\/src\/js\/*.js'],\ndest: 'client\/dist\/js\/build.js'\n<\/code><\/pre>\n<p><strong>Tested working example<\/strong> without writing files twice:<\/p>\n<pre><code>'use strict';\nmodule.exports = function(grunt) {\n  grunt.initConfig({\n    uglify: {\n      build: {\n        src: ['client\/src\/js\/*.js'],\n        dest: 'client\/dist\/js\/build.js'\n      }\n    },\n    watch: {\n      js: {\n        files: '',\n        tasks: ['uglify']\n      }\n    }\n  });\n  grunt.loadNpmTasks('grunt-contrib-uglify');\n  grunt.loadNpmTasks('grunt-contrib-watch');\n  grunt.registerTask('default', [\n    'uglify',\n    ]);\n  grunt.registerTask('dev', [\n    'watch'\n    ]);\n};\n<\/code><\/pre>\n<p>Notice that <code>''<\/code> is very handy \ud83d\ude09<\/p>\n<p><strong>Execution<\/strong><\/p>\n<pre><code>$ grunt watch\nRunning \"watch\" task\nWaiting...OK\n&gt;&gt; File \"client\/src\/js\/hello.js\" changed.\nRunning \"uglify:build\" (uglify) task\nFile \"client\/dist\/js\/build.js\" created.\nUncompressed size: 15 bytes.\nCompressed size: 32 bytes gzipped (15 bytes minified).\n\nDone, without errors.\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>I know this is marked as solved, but I still prefer this answer from a similar question because you can easily use the files again for another command without writing them twice. Basically, the answer says \/\/Does not work src: [&#8216;client\/src\/js\/*.js&#8217;], dest: [&#8216;client\/dist\/js\/build.js&#8217;] \/\/Works src: [&#8216;client\/src\/js\/*.js&#8217;], dest: &#8216;client\/dist\/js\/build.js&#8217; Tested working example without writing files twice: [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-2850","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/2850","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=2850"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/2850\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=2850"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=2850"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=2850"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}