| Leo Repp | 58b9f11 | 2021-11-22 11:57:47 +0100 | [diff] [blame^] | 1 | /* |
| 2 | * grunt-terser |
| 3 | * https://github.com/adascal/grunt-terser |
| 4 | * |
| 5 | * Copyright (c) 2018 Alexandr Dascal |
| 6 | * Licensed under the MIT license. |
| 7 | */ |
| 8 | |
| 9 | 'use strict'; |
| 10 | |
| 11 | module.exports = function(grunt) { |
| 12 | |
| 13 | // Project configuration. |
| 14 | grunt.initConfig({ |
| 15 | jshint: { |
| 16 | all: [ |
| 17 | 'Gruntfile.js', |
| 18 | 'tasks/*.js', |
| 19 | '<%= nodeunit.tests %>' |
| 20 | ], |
| 21 | options: { |
| 22 | jshintrc: '.jshintrc' |
| 23 | } |
| 24 | }, |
| 25 | |
| 26 | // Before generating any new files, remove any previously-created files. |
| 27 | clean: { |
| 28 | tests: ['tmp'] |
| 29 | }, |
| 30 | |
| 31 | // Configuration to be run (and then tested). |
| 32 | terser: { |
| 33 | default_options: { |
| 34 | options: { |
| 35 | }, |
| 36 | files: { |
| 37 | 'tmp/default_options': ['test/fixtures/testing', 'test/fixtures/123'] |
| 38 | } |
| 39 | }, |
| 40 | custom_options: { |
| 41 | options: { |
| 42 | separator: ': ', |
| 43 | punctuation: ' !!!' |
| 44 | }, |
| 45 | files: { |
| 46 | 'tmp/custom_options': ['test/fixtures/testing', 'test/fixtures/123'] |
| 47 | } |
| 48 | } |
| 49 | }, |
| 50 | |
| 51 | // Unit tests. |
| 52 | nodeunit: { |
| 53 | tests: ['test/*_test.js'] |
| 54 | } |
| 55 | |
| 56 | }); |
| 57 | |
| 58 | // Actually load this plugin's task(s). |
| 59 | grunt.loadTasks('tasks'); |
| 60 | |
| 61 | // These plugins provide necessary tasks. |
| 62 | grunt.loadNpmTasks('grunt-contrib-jshint'); |
| 63 | grunt.loadNpmTasks('grunt-contrib-clean'); |
| 64 | grunt.loadNpmTasks('grunt-contrib-nodeunit'); |
| 65 | |
| 66 | // Whenever the "test" task is run, first clean the "tmp" dir, then run this |
| 67 | // plugin's task(s), then test the result. |
| 68 | grunt.registerTask('test', ['clean', 'terser', 'nodeunit']); |
| 69 | |
| 70 | // By default, lint and run all tests. |
| 71 | grunt.registerTask('default', ['jshint', 'test']); |
| 72 | |
| 73 | }; |