Skip to content

Instantly share code, notes, and snippets.

@tyler6699
Created August 14, 2019 11:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tyler6699/aa0bdca55796553e42f2abc519f8132d to your computer and use it in GitHub Desktop.
Save tyler6699/aa0bdca55796553e42f2abc519f8132d to your computer and use it in GitHub Desktop.
grunt setup
@Carelesslabs
A simple Grunt setup for JS13kGames
This gruntfile will take all javascript files in source folder "assets/js/*.js" and compress them into
a single file "dst/game.min.js". Storing you minified HTML file and images in the dst folder also allows you
to compress this one dst folder for submission.
If you want individual files then change "expand: false," to " expand: true,". The "ext: '.min.js'" setting will tag min.js onto
all of the separate files.
Grunt will need to be installed: https://gruntjs.com/installing-grunt
running "grunt" from within your project will minify all of the js files, running "grunt watch" will listen for
changes and automatically minify.
******************************************************
// Gruntfile.js
******************************************************
module.exports = function(grunt) {
// Project configuration.
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
uglify: {
build: {
files: [{
expand: false,
src: 'assets/js/*.js',
dest: 'dst/game.min.js',
ext: '.min.js'
}]
}
},
watch: {
files: ['assets/js/*.js'],
tasks: ['uglify']
}
});
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.registerTask('default', ['uglify']);
};
******************************************************
// package.json
******************************************************
{
"name": "grunt-getting-started",
"version": "0.1.0",
"devDependencies": {
"grunt": "~0.4.4",
"grunt-contrib-uglify": "latest",
"grunt-contrib-less": "latest",
"grunt-contrib-cssmin": "latest",
"grunt-contrib-watch": "latest"
}
}
@tyler6699
Copy link
Author

If you want to use ES then use:
grunt-contrib-uglify-es

Search for "grunt-contrib-uglify" and replace it with grunt-contrib-uglify-es

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment