On Github martinp / grunt-slides
Martin Polden, Bouvet ASA18. september 2013
# Installer Grunt CLI $ npm install -g grunt-cli # Installer Grunt og jshint task $ npm install grunt grunt-contrib-jshint --save-dev # Opprett Gruntfile.js i prosjektrot $ $EDITOR Gruntfile.js
Gruntfile.js for denne presentasjonen
/* Gruntfile.js */ module.exports = function (grunt) { grunt.loadNpmTasks('grunt-contrib-jshint'); grunt.loadNpmTasks('grunt-contrib-connect'); grunt.loadNpmTasks('grunt-contrib-copy'); grunt.loadNpmTasks('grunt-contrib-nodeunit'); grunt.loadNpmTasks('grunt-contrib-watch'); grunt.loadNpmTasks('grunt-jsbeautifier');
grunt.initConfig({ jshint: { all: ['Gruntfile.js', 'test/**/*.js'], options: { indent: 2, quotmark: 'single', maxlen: 80 }, },
grunt.initConfig({ ... connect: { server: { options: { hostname: '*' } } },
grunt.initConfig({ ... copy: { main: { files: [{ expand: true, cwd: 'bower_components/reveal.js/', src: ['js/reveal.min.js', 'css/reveal.min.css', 'css/theme/*.css', 'plugin/highlight/**', 'plugin/notes/**', 'lib/js/**' ], dest: '.' }, { expand: true, cwd: 'bower_components/highlightjs/styles/', src: '*.css', dest: 'css/highlightjs/' }] } },
grunt.initConfig({ ... watch: { scripts: { files: ['index.html', 'test/**/*.js'], tasks: ['jsbeautifier', 'jshint', 'test'], options: { livereload: true, spawn: false, atBegin: true } } },
grunt.initConfig({ ... jsbeautifier: { all: ['Gruntfile.js', 'index.html', 'test/**/*.js'], options: { html: { indentSize: 2 }, js: { indent_size: 2, jslint_happy: true, wrap_line_length: 80 } } },
grunt.initConfig({ ... nodeunit: { all: ['test/*_test.js'] }
... grunt.registerTask('pretty', 'jsbeautifier'); grunt.registerTask('test', 'nodeunit'); grunt.registerTask('w', ['connect', 'watch']); grunt.registerTask('default', ['jsbeautifier', 'jshint', 'nodeunit']);
$ grunt Running "jsbeautifier:all" (jsbeautifier) task Beautified 3 files, changed 0 files...OK Running "jshint:all" (jshint) task >> 2 files lint free. Running "nodeunit:all" (nodeunit) task Testing foo_test.js.OK >> 1 assertions passed (8ms) Done, without errors.