2
0
mirror of https://github.com/VinylDNS/vinyldns synced 2025-08-22 02:02:14 +00:00
vinyldns/modules/portal/Gruntfile.js

134 lines
5.1 KiB
JavaScript
Raw Normal View History

module.exports = function(grunt) {
2018-07-27 10:18:29 -04:00
const license = `/*
* Copyright 2018 Comcast Cable Communications Management, LLC
*
* Licensed under the Apache License, Version 2.0 (the \\"License\\");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an \\"AS IS\\" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/`;
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-karma');
grunt.loadNpmTasks('grunt-mocha-phantomjs');
grunt.loadNpmTasks('grunt-contrib-concat');
// Project configuration.
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
copy: {
// Collect all of the javascript and CSS files that we need (we'll combine them later)
main: {
files: [
{expand: true, flatten: true, src: ['node_modules/angular/angular.min.js'], dest: 'public/js'},
{expand: true, flatten: true, src: ['node_modules/bootstrap/dist/js/bootstrap.min.js'], dest: 'public/js'},
{expand: true, flatten: true, src: ['node_modules/jquery/dist/jquery.min.js'], dest: 'public/js'},
{expand: true, flatten: true, src: ['node_modules/moment/min/moment.min.js'], dest: 'public/js'},
{expand: true, flatten: true, src: ['node_modules/bootstrap/dist/css/bootstrap.min.css'], dest: 'public/css'},
{expand: true, flatten: true, src: ['node_modules/font-awesome/css/font-awesome.min.css'], dest: 'public/css'},
// We're picking just the resources we need from the gentelella UI framework and temporarily storing them in mapped/ui/
{expand: true, flatten: true, cwd: 'node_modules/gentelella', dest: 'mapped/ui', src: '**/jquery.{smartWizard,mCustomScrollbar.concat.min,dataTables.min,mousewheel.min}.js'},
{expand: true, flatten: true, cwd: 'node_modules/gentelella', dest: 'mapped/ui', src: '**/bootstrap-daterangepicker/daterangepicker.js'},
{expand: true, flatten: true, cwd: 'node_modules/gentelella', dest: 'mapped/ui', src: '**/build/css/custom.min.css'},
{expand: true, flatten: true, cwd: 'node_modules/gentelella', dest: 'mapped/ui', src: '**/{daterangepicker,animate.min}.css'},
{expand: true, flatten: true, cwd: 'node_modules/gentelella', dest: 'public/fonts', src: '**/fonts/*.{woff,woff2,ttf}'},
{expand: true, flatten: true, src: ['public/custom/**/*.js', '!public/custom/**/*.spec.js'], dest: 'public/js'},
{expand: true, flatten: true, src: ['public/custom/**/*.css'], dest: 'public/css'},
],
},
// Unit test files
unit: {
files: [
{expand: true, flatten: true, src: ['node_modules/angular-mocks/angular-mocks.js'], dest: 'public/test_frameworks'},
{expand: true, flatten: true, src: ['node_modules/jasmine-jquery/lib/jasmine-jquery.js'], dest: 'public/test_frameworks'},
],
},
},
// Unit test configuration
karma: {
unit: {
configFile: 'karma.conf.js',
},
},
// Combine multiple files to make it easier to import and use them
concat: {
options: {
sourceMap: true,
},
css: {
files: {
'public/css/ui.css': ['mapped/ui/*.css'],
},
},
vinyldns: {
options: {
banner: license,
separator: ';\n',
process: (src, filepath) => {
return '/* Source: ' + filepath + '*/\n' +
src.replace(/(^|\n)[ \t]*('use strict'|"use strict");?\s*/g, '$1').replace(/\/\*.+?\*\//gs, '').replace(/\n{2,}/g, '\n');
},
},
files: {
'public/js/vinyldns.js': [
'public/lib/**/*.module.js',
'public/lib/**/*.js',
'!public/lib/**/*.spec.js',
],
},
},
ui_javascript: {
options: {
separator: ';\n',
process: (src, filepath) => {
return '/* Source: ' + filepath + ' */\n' +
src.replace(/(^|\n)[ \t]*('use strict'|"use strict");?\s*/g, '$1');
},
2018-07-27 10:18:29 -04:00
},
files: {
'public/js/ui.js': ['mapped/ui/**/*.js'],
2018-07-27 10:18:29 -04:00
},
},
ui_css: {
options: {
separator: '\n',
process: (src, filepath) => {
return '/* Source: ' + filepath + ' */\n' + src;
},
2018-07-27 10:18:29 -04:00
},
files: {
'public/css/ui.css': ['mapped/ui/**/*.css'],
2018-07-27 10:18:29 -04:00
},
},
},
2018-07-27 10:18:29 -04:00
clean: {
js: ['public/js/*', '!public/js/custom.js'],
css: ['public/css/*', '!public/css/{theme-overrides,vinyldns}.css'],
mapped: ['mapped/'],
fonts: ['public/fonts'],
unit: ['public/test_frameworks/*'],
},
});
2018-07-27 10:18:29 -04:00
// Default task
grunt.registerTask('default', ['clean', 'copy:main', 'concat', 'clean:mapped']);
// Unit tests
grunt.registerTask('unit', ['default', 'copy:unit', 'karma:unit', 'clean:unit']);
2018-07-27 10:18:29 -04:00
};