diff --git a/Gruntfile.js b/Gruntfile.js index 1218a46c..574a0a7d 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -1,61 +1,56 @@ -/*global module:false*/ -module.exports = function(grunt){ +module.exports = function (grunt) { + const srcFiles = 'src/**/*.js'; + const distDir = 'dist/'; - - // Project configuration. - grunt.initConfig({ - pkg: grunt.file.readJSON('package.json'), - bower: grunt.file.readJSON('bower.json'), - copy: { - demo: { - files: [ - {expand: true, src: ['src/*'], dest: 'dist/', filter: 'isFile', flatten: true} - ] - } - }, + grunt.initConfig({ + pkg: grunt.file.readJSON('package.json'), + bower: grunt.file.readJSON('bower.json'), - uglify: { - options: { - beautify: { - ascii_only : true - }, - preserveComments: 'some' - }, - html5shiv: { - files: [{ - expand: true, // Enable dynamic expansion. - cwd: 'src/', // Src matches are relative to this path. - src: ['**/*.js'], // Actual pattern(s) to match. - dest: 'dist/', // Destination path prefix. - ext: '.min.js' - }] - } - }, - watch: { - js: { - files: ['src/**/*.js'], - tasks: ['copy', 'uglify', 'bytesize'] - } - }, - bytesize: { - all: { - src: [ - 'dist/**.min.js' - ] - } - } - }); + copy: { + demo: { + files: [ + { expand: true, cwd: 'src/', src: ['*'], dest: distDir, flatten: true } + ] + } + }, - - // Default task. + uglify: { + options: { + beautify: { ascii_only: true }, + preserveComments: 'some' + }, + html5shiv: { + files: [{ + expand: true, + cwd: 'src/', + src: ['**/*.js'], + dest: distDir, + ext: '.min.js' + }] + } + }, - + watch: { + js: { + files: [srcFiles], + tasks: ['copy', 'uglify', 'bytesize'] + } + }, - grunt.loadNpmTasks('grunt-contrib-copy'); - grunt.loadNpmTasks('grunt-contrib-uglify'); - grunt.loadNpmTasks('grunt-contrib-watch'); - grunt.loadNpmTasks('grunt-bytesize'); + bytesize: { + all: { + src: [`${distDir}*.min.js`] + } + } + }); - grunt.registerTask('default', ['copy', 'uglify', 'bytesize', 'watch']); + [ + 'grunt-contrib-copy', + 'grunt-contrib-uglify', + 'grunt-contrib-watch', + 'grunt-bytesize' + ].forEach(task => grunt.loadNpmTasks(task)); + grunt.registerTask('default', ['copy', 'uglify', 'bytesize']); + grunt.registerTask('dev', ['default', 'watch']); };