Newer
Older

Rafael Ostertag
committed
var path = require('path');
var typo3_css = 'extension/Resources/Public/Css/';
var typo3_js = 'extension/Resources/Public/JavaScript/';
var typo3_fonts = 'extension/Resources/Public/fonts/';

Rafael Ostertag
committed
var js_sources = [
'javascript/src/Helper/*.js',
'javascript/src/Element/*.js',

Rafael Ostertag
committed
'javascript/src/*.js'
];
// Project configuration.
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
copy: {
bootstrap: {
files: [
{
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
}
]
},

Rafael Ostertag
committed
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
}
]
},

Rafael Ostertag
committed
},
{
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

Rafael Ostertag
committed
},
{
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
}
]
},
'jqx.bootstrap.css'
},
{
cwd: 'bower_components/jqwidgets/jqwidgets/styles/',
src: [
'images/**'
],
expand: true,
},
jqwidgets_devel: {
files: [
{
cwd: 'bower_components/jqwidgets/jqwidgets/',
src: [
'jqx-all.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/'
}
]

Rafael Ostertag
committed
},
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: [
'javascript/src/*.js'
]
},

Rafael Ostertag
committed
concat_in_order: {

Rafael Ostertag
committed
debug_standalone: {

Rafael Ostertag
committed
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
}

Rafael Ostertag
committed
},
debug_extension: {

Rafael Ostertag
committed
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
}
"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"
banner: "/* Change qfq-bs.css.less, not qfq-bs.css */"

Rafael Ostertag
committed
unit: {
src: ['tests/jasmine/unit/spec/*Spec.js'],
options: {
vendor: [
'js/jquery.min.js',
'js/bootstrap.min.js',

Rafael Ostertag
committed
'js/EventEmitter.min.js',
'js/qfq.debug.js'
helpers: ['tests/jasmine/helper/mock-ajax.js'],

Rafael Ostertag
committed
template: 'tests/jasmine/unit/SpecRunner.tmpl'
watch: {
scripts: {
files: [
'javascript/src/Element/*.js',

Rafael Ostertag
committed
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');

Rafael Ostertag
committed
grunt.loadNpmTasks('grunt-concat-in-order');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-jasmine');

Rafael Ostertag
committed
grunt.registerTask('default', ['jshint', 'concat_in_order', 'uglify', 'copy', 'less']);

Rafael Ostertag
committed
grunt.registerTask('run-jasmine', ['jshint', 'concat_in_order', 'jasmine']);