var path = require('path'); module.exports = function (grunt) { 'use strict'; var typo3_css = 'extension/Resources/Public/Css/'; var typo3_js = 'extension/Resources/Public/JavaScript/'; var typo3_fonts = 'extension/Resources/Public/fonts/'; var js_sources = [ 'javascript/src/Helper/*.js', 'javascript/src/Element/*.js', 'javascript/src/*.js' ]; // Project configuration. grunt.initConfig({ pkg: grunt.file.readJSON('package.json'), copy: { bootstrap: { files: [ { cwd: 'bower_components/bootstrap/dist/css/', src: [ 'bootstrap.min.css', 'bootstrap-theme.min.css' ], dest: typo3_css, filter: 'isFile', expand: true, flatten: true }, { cwd: 'bower_components/bootstrap/dist/js/', src: [ 'bootstrap.min.js' ], dest: typo3_js, expand: true, flatten: true }, { cwd: 'bower_components/bootstrap/dist/fonts/', expand: true, src: [ '*' ], dest: typo3_fonts, flatten: true } ] }, bootstrap_dev: { files: [ { cwd: 'bower_components/bootstrap/dist/css/', src: [ 'bootstrap.min.css', 'bootstrap-theme.min.css' ], dest: 'css/', filter: 'isFile', expand: true, flatten: true }, { cwd: 'bower_components/bootstrap/dist/js/', src: [ 'bootstrap.min.js' ], dest: 'js/', expand: true, flatten: true }, { cwd: 'bower_components/bootstrap/dist/fonts/', expand: true, src: [ '*' ], dest: 'fonts/', flatten: true } ] }, bootstrap_validator: { files: [ { cwd: 'bower_components/bootstrap-validator/dist/', src: [ 'validator.min.js' ], dest: 'js/', expand: true, flatten: true }, { cwd: 'bower_components/bootstrap-validator/dist/', src: [ 'validator.min.js' ], dest: typo3_js, expand: true, flatten: true } ] }, jquery: { files: [ { cwd: 'bower_components/jquery/dist/', src: [ 'jquery.min.js' ], expand: true, dest: typo3_js, flatten: true }, { cwd: 'bower_components/jquery/dist/', src: [ 'jquery.min.js' ], expand: true, dest: "js/", flatten: true } ] }, jquery_tablesorter: { files: [ { cwd: 'bower_components/tablesorter/dist/js/', src: [ 'jquery.tablesorter.min.js' ], expand: true, dest: typo3_js, flatten: true }, { cwd: 'bower_components/tablesorter/dist/js/', src: [ 'jquery.tablesorter.min.js', 'jquery.tablesorter.widgets.min.js', 'widgets/widget-grouping.min.js' ], expand: true, dest: 'js/', flatten: true } ] }, ChartJS: { files: [ { cwd: 'bower_components/Chart.js/dist/', src: [ 'Chart.min.js' ], expand: true, dest: typo3_js, flatten: true }, { cwd: 'bower_components/Chart.js/dist/', src: [ 'Chart.min.js' ], expand: true, dest: "js/", flatten: true } ] }, jqwidgets: { files: [ { cwd: 'bower_components/jqwidgets/jqwidgets/', src: [ 'jqx-all.js', 'globalization/globalize.js' ], expand: true, dest: typo3_js, flatten: true }, { cwd: 'bower_components/jqwidgets/jqwidgets/styles/', src: [ 'jqx.base.css', 'jqx.bootstrap.css' ], expand: true, dest: typo3_css, flatten: true }, { cwd: 'bower_components/jqwidgets/jqwidgets/styles/', src: [ 'images/**' ], expand: true, dest: typo3_css } ] }, jqwidgets_devel: { files: [ { cwd: 'bower_components/jqwidgets/jqwidgets/', src: [ 'jqx-all.js', 'globalization/globalize.js' ], expand: true, dest: 'js/', flatten: true }, { cwd: 'bower_components/jqwidgets/jqwidgets/styles/', src: [ 'jqx.base.css', 'jqx.bootstrap.css' ], expand: true, dest: 'css/', flatten: true }, { cwd: 'bower_components/jqwidgets/jqwidgets/styles/', src: [ 'images/**' ], expand: true, dest: 'css/' } ] }, tinymce: { files: [ { cwd: 'bower_components/tinymce/', src: [ 'tinymce.min.js' ], expand: true, dest: typo3_js, flatten: true }, { cwd: 'bower_components/tinymce/', src: [ 'themes/*/theme.min.js' ], dest: typo3_js, expand: true, // Tiny MCE expects the theme js files in ./themes. flatten: false }, { cwd: 'bower_components/tinymce/', src: [ 'skins/**' ], dest: typo3_js, expand: true, // Tiny MCE expects the theme js files in ./themes. flatten: false } ] }, tinymce_devel: { files: [ { cwd: 'bower_components/tinymce/', src: [ 'tinymce.min.js' ], expand: true, dest: 'js/', flatten: true }, { cwd: 'bower_components/tinymce/', src: [ 'themes/*/theme.min.js' ], dest: 'js/', expand: true, // Tiny MCE expects the theme js files in ./themes. flatten: false }, { cwd: 'bower_components/tinymce/', src: [ 'skins/**' ], dest: 'js/', expand: true, // Tiny MCE expects the theme js files in ./themes. flatten: false } ] }, eventEmitter: { files: [ { cwd: 'bower_components/eventEmitter/', src: [ 'EventEmitter.min.js' ], expand: true, dest: typo3_js, flatten: true }, { cwd: 'bower_components/eventEmitter/', src: [ 'EventEmitter.min.js' ], expand: true, dest: 'js/', flatten: true } ] } }, uglify: { options: { banner: '/*! <%= pkg.name %> <%= grunt.template.today("yyyy-mm-dd") %> */\n', }, build: { src: ['js/<%= pkg.name %>.debug.js'], dest: typo3_js + '<%= pkg.name %>.min.js' } }, jshint: { all: js_sources }, concat_in_order: { debug_standalone: { options: { extractRequired: function (filepath, filecontent) { var workingdir = path.normalize(filepath).split(path.sep); workingdir.pop(); var deps = this.getMatches(/\*\s*@depend\s(.*\.js)/g, filecontent); deps.forEach(function (dep, i) { var dependency = workingdir.concat([dep]); deps[i] = path.join.apply(null, dependency); }); return deps; }, extractDeclared: function (filepath) { return [filepath]; }, onlyConcatRequiredFiles: false }, files: { 'js/<%= pkg.name %>.debug.js': js_sources } }, debug_extension: { options: { extractRequired: function (filepath, filecontent) { var workingdir = path.normalize(filepath).split(path.sep); workingdir.pop(); var deps = this.getMatches(/\*\s*@depend\s(.*\.js)/g, filecontent); deps.forEach(function (dep, i) { var dependency = workingdir.concat([dep]); deps[i] = path.join.apply(null, dependency); }); return deps; }, extractDeclared: function (filepath) { return [filepath]; }, onlyConcatRequiredFiles: false }, files: { 'extension/Resources/Public/JavaScript/<%= pkg.name %>.debug.js': js_sources } } }, less: { production: { files: { "extension/Resources/Public/Css/qfq-bs.css": "less/qfq-bs.css.less", "extension/Resources/Public/Css/qfq-plain.css": "less/qfq-plain.css.less", "extension/Resources/Public/Css/bs-tablesorter.css": "less/bs-tablesorter.less" }, options: { compress: true } }, devel: { files: { "css/qfq-bs.css": "less/qfq-bs.css.less", "css/qfq-plain.css": "less/qfq-plain.css.less", "css/bs-tablesorter.css": "less/bs-tablesorter.less" }, options: { banner: "/* Change qfq-bs.css.less, not qfq-bs.css */" } } }, jasmine: { unit: { src: ['tests/jasmine/unit/spec/*Spec.js'], options: { vendor: [ 'js/jquery.min.js', 'js/bootstrap.min.js', 'js/EventEmitter.min.js', 'js/jqx-all.js', 'js/qfq.debug.js' ], helpers: ['tests/jasmine/helper/mock-ajax.js'], template: 'tests/jasmine/unit/SpecRunner.tmpl' } } }, watch: { scripts: { files: js_sources.concat(['less/*.less']), tasks: ['default'], options: { spawn: true } } } }); // Load the plugin that provides the "uglify" task. grunt.loadNpmTasks('grunt-contrib-uglify'); grunt.loadNpmTasks('grunt-contrib-copy'); grunt.loadNpmTasks('grunt-contrib-concat'); grunt.loadNpmTasks('grunt-concat-in-order'); grunt.loadNpmTasks('grunt-contrib-jshint'); grunt.loadNpmTasks('grunt-contrib-watch'); grunt.loadNpmTasks('grunt-contrib-less'); grunt.loadNpmTasks('grunt-contrib-jasmine'); // Default task(s). grunt.registerTask('default', ['jshint', 'concat_in_order', 'uglify', 'copy', 'less']); grunt.registerTask('run-jasmine', ['jshint', 'concat_in_order', 'jasmine']); };