Your Gruntfile.js should be in the root of the directory ie ls should show src/ build/ Gruntfile.js
The content of `Gruntfile.js that meets your requirements:
module.exports = function (grunt) { grunt.initConfig({ pkg: grunt.file.readJSON('package.json'), concat: { js: { src: [ 'src/js/*', 'src/lib/*' ], dest: 'build/js/combined.js' } }, uglify: { js: { files: { 'build/js/main.js': ['build/js/combined.js'] } } }, }); grunt.loadNpmTasks('grunt-contrib-concat'); grunt.loadNpmTasks('grunt-contrib-uglify'); grunt.registerTask('default', ['concat:js', 'uglify:js']); };
I do not think require-js will be used here. require-js is useful when you need to load your js scripts in a specific order. If so, add the code below to Gruntfile.js just below pkg: grunt.file.readJSON('package.json'), line
requirejs: { compile: { options: { baseUrl: "path/to/base", mainConfigFile: "path/to/config.js", name: "path/to/almond", // assumes a production build using almond out: "path/to/optimized.js" } } }
source share