├── .gitignore ├── README.md ├── package.json └── gulpfile.js /.gitignore: -------------------------------------------------------------------------------- 1 | build/ 2 | node_modules/ 3 | dist/ -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # js13k-toolkit 2 | A simple little tool for developing a JS game while keeping it under 13kb zipped 3 | 4 | Run `gulp init` to create a simple folder structure. 5 | 6 | Run `gulp watch --silent` (silent optional) to have gulp continuously build your project and check it's compressed zip file size. A warning will be printed if you exceed 13312 bytes (13kb) to ensure you're under the limit for the js13kgames competition. 7 | 8 | Feel free to edit the gulpfile to suit your specific needs. -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "js13k-toolkit", 3 | "version": "2.0.0", 4 | "description": "A simple tool for developing a JS game while keeping it under 13kb zipped", 5 | "main": "gulpfile.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "repository": { 10 | "type": "git", 11 | "url": "https://github.com/lucaspenney/js13k-toolkit.git" 12 | }, 13 | "author": "", 14 | "license": "MIT", 15 | "bugs": { 16 | "url": "https://github.com/lucaspenney/js13k-toolkit/issues" 17 | }, 18 | "dependencies": {}, 19 | "devDependencies": { 20 | "chalk": "^1.1.3", 21 | "gulp": "github:gulpjs/gulp#4.0", 22 | "gulp-concat": "^2.6.0", 23 | "gulp-cssmin": "^0.1.7", 24 | "gulp-htmlmin": "^2.0.0", 25 | "gulp-uglify": "^2.0.0", 26 | "gulp-watch": "^4.3.9", 27 | "gulp-zip": "^3.2.0", 28 | "mkdirp": "^0.5.1" 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /gulpfile.js: -------------------------------------------------------------------------------- 1 | var gulp = require('gulp'); 2 | var uglify = require('gulp-uglify'); 3 | var htmlmin = require('gulp-htmlmin'); 4 | var cssmin = require('gulp-cssmin'); 5 | var concat = require('gulp-concat'); 6 | var zip = require('gulp-zip'); 7 | var fs = require('fs'); 8 | var mkdirp = require('mkdirp'); 9 | var chalk = require('chalk'); 10 | var watch = require('gulp-watch'); 11 | 12 | //Chalk colors 13 | var error = chalk.bold.red; 14 | var success = chalk.green; 15 | var regular = chalk.white; 16 | 17 | gulp.task('watch', (done) => { 18 | gulp.watch('./src/js/**/*.js', gulp.series('build-js', 'zip', 'check')); 19 | gulp.watch('./src/html/**/*.html', gulp.series('build-html', 'check')); 20 | gulp.watch('./src/css/**/*.css', gulp.series('build-css', 'check')); 21 | gulp.watch('./src/assets/**/*', gulp.series('build-assets', 'check')); 22 | }); 23 | 24 | gulp.task('init', (done) => { 25 | //Create our directory structure 26 | mkdirp('./src', function (err) { 27 | mkdirp('./src/js', function (err) { 28 | mkdirp('./src/html', function (err) { 29 | mkdirp('./src/css', function (err) { 30 | mkdirp('./src/assets', function (err) { 31 | done(); 32 | }); 33 | }); 34 | }); 35 | }); 36 | }); 37 | }); 38 | 39 | gulp.task('build-js', (done) => { 40 | return gulp.src('./src/js/**/*.js') 41 | .pipe(concat('game.js')) 42 | .pipe(uglify()) 43 | .pipe(gulp.dest('./build/')); 44 | }); 45 | 46 | gulp.task('build-html', (done) => { 47 | return gulp.src('./src/html/**/*.html') 48 | .pipe(htmlmin({collapseWhitespace: true})) 49 | .pipe(gulp.dest('./build/')); 50 | }); 51 | 52 | gulp.task('build-css', (done) => { 53 | return gulp.src('./src/css/**/*.css') 54 | .pipe(cssmin()) 55 | .pipe(gulp.dest('./build/')); 56 | }); 57 | 58 | gulp.task('build-assets', (done) => { 59 | return gulp.src('./src/assets/**/*') 60 | .pipe(gulp.dest('./build/')); 61 | }); 62 | 63 | gulp.task('zip', (done) => { 64 | return gulp.src('./build/**/*') 65 | .pipe(zip('entry.zip')) //gulp-zip performs compression by default 66 | .pipe(gulp.dest('dist')); 67 | }); 68 | 69 | gulp.task('check', gulp.series('zip', (done) => { 70 | var stats = fs.statSync("./dist/entry.zip") 71 | var fileSize = stats.size; 72 | if (fileSize > 13312) { 73 | console.log(error("Your zip compressed game is larger than 13kb (13312 bytes)!")) 74 | console.log(regular("Your zip compressed game is " + fileSize + " bytes")); 75 | } else { 76 | console.log(success("Your zip compressed game is " + fileSize + " bytes.")); 77 | } 78 | done(); 79 | })); 80 | 81 | gulp.task('build', gulp.series('build-html', 'build-js', 'build-assets', 'check', (done) => { 82 | done(); 83 | })); --------------------------------------------------------------------------------