Created
August 14, 2019 11:59
-
-
Save tyler6699/aa0bdca55796553e42f2abc519f8132d to your computer and use it in GitHub Desktop.
grunt setup
This file contains hidden or 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
@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" | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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