Last active
May 17, 2024 03:38
-
-
Save Gaya/7498780 to your computer and use it in GitHub Desktop.
Gruntfile.js file for concatenation and watch tasks.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = function(grunt) { | |
// Project configuration. | |
grunt.initConfig({ | |
pkg: grunt.file.readJSON('package.json'), | |
concat: { | |
options: { | |
separator: "\n", //add a new line after each file | |
banner: "", //added before everything | |
footer: "" //added after everything | |
}, | |
dist: { | |
// the files to concatenate | |
src: [ | |
//include libs | |
'libs/somelib/somelib.js', | |
'libs/otherlib/otherlib.js', | |
//own classes and files | |
'src/**/!(base).js', | |
//the last script I need | |
'src/base.js' | |
], | |
// the location of the resulting JS file | |
dest: 'js/<%= pkg.name %>.js' | |
} | |
}, | |
watch: { | |
scripts: { | |
files: ['src/**/*.js'], | |
tasks: ['dev-watch'], | |
options: { | |
interrupt: true | |
} | |
} | |
}, | |
removelogging: { | |
dist: { | |
src: "js/<%= pkg.name %>.js", | |
dest: "build/<%= pkg.name %>.js" | |
} | |
}, | |
uglify: { | |
options: { | |
banner: "" | |
}, | |
build: { | |
src: 'build/<%= pkg.name %>.js', | |
dest: 'js/<%= pkg.name %>.min.js' | |
} | |
} | |
}); | |
//load the packages | |
grunt.loadNpmTasks('grunt-contrib-concat'); | |
grunt.loadNpmTasks('grunt-contrib-watch'); | |
grunt.loadNpmTasks('grunt-remove-logging'); | |
grunt.loadNpmTasks('grunt-contrib-uglify'); | |
//register the task | |
grunt.registerTask('dev-watch', ['concat:dist']); | |
grunt.registerTask('build', ['concat', 'removelogging', 'uglify']); | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = function(grunt) { | |
// Project configuration. | |
grunt.initConfig({ | |
pkg: grunt.file.readJSON('package.json'), | |
concat: { | |
options: { | |
separator: "\n", //add a new line after each file | |
banner: "", //added before everything | |
footer: "" //added after everything | |
}, | |
dist: { | |
// the files to concatenate | |
src: [ | |
//include libs | |
'libs/somelib/somelib.js', | |
'libs/otherlib/otherlib.js', | |
//own classes and files | |
'src/**/!(base).js', | |
//the last script I need | |
'src/base.js' | |
], | |
// the location of the resulting JS file | |
dest: 'js/<%= pkg.name %>.js' | |
} | |
}, | |
watch: { | |
scripts: { | |
files: ['src/**/*.js'], | |
tasks: ['dev-watch'], | |
options: { | |
interrupt: true | |
} | |
} | |
} | |
}); | |
grunt.loadNpmTasks('grunt-contrib-concat'); | |
grunt.loadNpmTasks('grunt-contrib-watch'); | |
//register the task | |
grunt.registerTask('dev-watch', ['concat:dist']); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment