|
| 1 | +module.exports = function(grunt) { |
| 2 | + |
| 3 | + grunt.initConfig({ |
| 4 | + pkg: grunt.file.readJSON('package.json'), |
| 5 | + |
| 6 | + // Throw all our JS-files into one |
| 7 | + concat: { |
| 8 | + options: { |
| 9 | + separator: ';' |
| 10 | + }, |
| 11 | + dist: { |
| 12 | + src: ['public/js/zettlr.editor.js', |
| 13 | + 'public/js/zettlr.helper.js', |
| 14 | + 'public/js/zettlr.media-library.js'], |
| 15 | + dest: 'public/js/<%= pkg.name %>.js' |
| 16 | + } |
| 17 | + }, |
| 18 | + |
| 19 | + // Minify them |
| 20 | + uglify: { |
| 21 | + options: { |
| 22 | + banner: '/* <%= pkg.name %> <%= grunt.template.today("yyyy-mm-dd") %> */\n' |
| 23 | + }, |
| 24 | + dist: { |
| 25 | + files: { |
| 26 | + 'public/js/<%= pkg.name %>.min.js' : ['<%= concat.dist.dest %>'] |
| 27 | + } |
| 28 | + } |
| 29 | + }, |
| 30 | + |
| 31 | + // Use JSHint for validating the file |
| 32 | + jshint: { |
| 33 | + files: ['Gruntfile.js', 'public/js/zettlr.*.js'], |
| 34 | + options: { |
| 35 | + globals: { |
| 36 | + jQuery: true, |
| 37 | + console: true, |
| 38 | + module: true, |
| 39 | + document: true |
| 40 | + }, |
| 41 | + // We need multistr for our Medialibrary, as it also brings HTML with line escapings (\) |
| 42 | + // TODO: Will be removed in next jshint release, so then we can remove it here as well |
| 43 | + multistr: true |
| 44 | + } |
| 45 | + }, |
| 46 | + |
| 47 | + // Watchdog to watch for changes |
| 48 | + watch: { |
| 49 | + files: ['<%= jshint.files %>'], |
| 50 | + tasks: ['jshint'] |
| 51 | + } |
| 52 | + }); |
| 53 | + |
| 54 | + grunt.loadNpmTasks('grunt-contrib-uglify'); |
| 55 | + grunt.loadNpmTasks('grunt-contrib-jshint'); |
| 56 | + grunt.loadNpmTasks('grunt-contrib-watch'); |
| 57 | + grunt.loadNpmTasks('grunt-contrib-concat'); |
| 58 | + |
| 59 | + // Register default task |
| 60 | + grunt.registerTask('default', ['jshint', 'concat', 'uglify']); |
| 61 | + grunt.registerTask('build', ['jshint', 'concat', 'uglify']) |
| 62 | +}; |
0 commit comments