1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-17 16:42:48 +01:00
invoiceninja/Gruntfile.js

186 lines
7.3 KiB
JavaScript
Raw Normal View History

2016-07-21 14:35:23 +02:00
module.exports = function(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
dump_dir: (function() {
var out = {};
2016-07-26 22:04:25 +02:00
2016-07-21 14:35:23 +02:00
grunt.file.expand({ filter: 'isDirectory'}, 'public/fonts/invoice-fonts/*').forEach(function(path) {
var fontName = /[^/]*$/.exec(path)[0],
files = {},
license='';
2016-07-26 22:04:25 +02:00
2016-07-21 14:35:23 +02:00
// Add license text
grunt.file.expand({ filter: 'isFile'}, path+'/*.txt').forEach(function(path) {
var licenseText = grunt.file.read(path);
// Fix anything that could escape from the comment
licenseText = licenseText.replace(/\*\//g,'*\\/');
license += "/*\n"+licenseText+"\n*/";
});
2016-07-26 22:04:25 +02:00
2016-07-21 14:35:23 +02:00
// Create files list
files['public/js/vfs_fonts/'+fontName+'.js'] = [path+'/*.ttf'];
2016-07-26 22:04:25 +02:00
2016-07-21 14:35:23 +02:00
out[fontName] = {
options: {
pre: license+'window.ninjaFontVfs=window.ninjaFontVfs||{};window.ninjaFontVfs.'+fontName+'=',
rootPath: path+'/'
},
files: files
};
2016-07-26 22:04:25 +02:00
});
2016-07-21 14:35:23 +02:00
// Return the computed object
return out;
}()),
concat: {
options: {
process: function(src, filepath) {
var basepath = filepath.substring(7, filepath.lastIndexOf('/') + 1);
// Fix relative paths for css files
if(filepath.indexOf('.css', filepath.length - 4) !== -1) {
return src.replace(/(url\s*[\("']+)\s*([^'"\)]+)(['"\)]+;?)/gi, function(match, start, url, end, offset, string) {
if(url.indexOf('data:') === 0) {
// Skip data urls
return match;
} else if(url.indexOf('/') === 0) {
// Skip absolute urls
return match;
} else {
return start + basepath + url + end;
}
});
// Fix source maps locations
} else if(filepath.indexOf('.js', filepath.length - 4) !== -1) {
return src.replace(/(\/[*\/][#@]\s*sourceMappingURL=)([^\s]+)/gi, function(match, start, url, offset, string) {
if(url.indexOf('/') === 0) {
// Skip absolute urls
return match;
} else {
return start + basepath + url;
}
});
// Don't do anything for unknown file types
} else {
return src;
}
},
},
js: {
src: [
'public/vendor/jquery/dist/jquery.js',
'public/vendor/jquery-ui/jquery-ui.min.js',
'public/vendor/bootstrap/dist/js/bootstrap.min.js',
'public/vendor/datatables/media/js/jquery.dataTables.js',
'public/vendor/datatables-bootstrap3/BS3/assets/js/datatables.js',
'public/vendor/knockout.js/knockout.js',
'public/vendor/knockout-mapping/build/output/knockout.mapping-latest.js',
'public/vendor/knockout-sortable/build/knockout-sortable.min.js',
'public/vendor/underscore/underscore.js',
'public/vendor/bootstrap-datepicker/dist/js/bootstrap-datepicker.min.js',
'public/vendor/bootstrap-datepicker/dist/locales/bootstrap-datepicker.de.min.js',
'public/vendor/bootstrap-datepicker/dist/locales/bootstrap-datepicker.da.min.js',
'public/vendor/bootstrap-datepicker/dist/locales/bootstrap-datepicker.pt-BR.min.js',
'public/vendor/bootstrap-datepicker/dist/locales/bootstrap-datepicker.nl.min.js',
'public/vendor/bootstrap-datepicker/dist/locales/bootstrap-datepicker.fr.min.js',
'public/vendor/bootstrap-datepicker/dist/locales/bootstrap-datepicker.it.min.js',
'public/vendor/bootstrap-datepicker/dist/locales/bootstrap-datepicker.lt.min.js',
'public/vendor/bootstrap-datepicker/dist/locales/bootstrap-datepicker.no.min.js',
'public/vendor/bootstrap-datepicker/dist/locales/bootstrap-datepicker.es.min.js',
'public/vendor/bootstrap-datepicker/dist/locales/bootstrap-datepicker.sv.min.js',
'public/vendor/dropzone/dist/min/dropzone.min.js',
'public/vendor/typeahead.js/dist/typeahead.jquery.min.js',
'public/vendor/accounting/accounting.min.js',
'public/vendor/spectrum/spectrum.js',
'public/vendor/jspdf/dist/jspdf.min.js',
'public/vendor/moment/min/moment.min.js',
'public/vendor/moment-timezone/builds/moment-timezone-with-data.min.js',
'public/vendor/stacktrace-js/dist/stacktrace-with-polyfills.min.js',
'public/vendor/fuse.js/src/fuse.min.js',
2016-07-28 18:55:23 +02:00
'public/vendor/sweetalert/dist/sweetalert.min.js',
2016-07-21 14:35:23 +02:00
//'public/vendor/moment-duration-format/lib/moment-duration-format.js',
//'public/vendor/pdfmake/build/pdfmake.min.js',
//'public/vendor/pdfmake/build/vfs_fonts.js',
//'public/js/vfs_fonts.js',
'public/js/bootstrap-combobox.js',
'public/js/script.js',
'public/js/pdf.pdfmake.js',
],
dest: 'public/built.js',
nonull: true
},
2016-07-23 23:57:08 +02:00
/*js_public: {
2016-07-21 14:35:23 +02:00
src: [
'public/js/simpleexpand.js',
'public/js/valign.js',
'public/js/bootstrap.min.js',
'public/js/simpleexpand.js',
'public/vendor/bootstrap/dist/js/bootstrap.min.js',
'public/js/bootstrap-combobox.js',
],
dest: 'public/built.public.js',
nonull: true
2016-07-29 16:10:38 +02:00
},
2016-07-21 14:35:23 +02:00
css: {
src: [
'public/vendor/bootstrap/dist/css/bootstrap.min.css',
'public/vendor/datatables/media/css/jquery.dataTables.css',
'public/vendor/datatables-bootstrap3/BS3/assets/css/datatables.css',
'public/vendor/font-awesome/css/font-awesome.min.css',
'public/vendor/bootstrap-datepicker/dist/css/bootstrap-datepicker3.css',
'public/vendor/dropzone/dist/min/dropzone.min.css',
'public/vendor/spectrum/spectrum.css',
'public/css/bootstrap-combobox.css',
'public/css/typeahead.js-bootstrap.css',
2016-07-28 18:55:23 +02:00
'public/vendor/sweetalert/dist/sweetalert.css',
2016-07-21 14:35:23 +02:00
'public/css/style.css',
],
dest: 'public/css/built.css',
nonull: true,
options: {
process: false
}
2016-07-29 16:10:38 +02:00
},*/
2016-07-26 11:46:15 +02:00
/*css_public: {
2016-07-21 14:35:23 +02:00
src: [
'public/vendor/bootstrap/dist/css/bootstrap.min.css',
'public/vendor/font-awesome/css/font-awesome.min.css',
'public/css/bootstrap-combobox.css',
'public/vendor/datatables/media/css/jquery.dataTables.css',
'public/vendor/datatables-bootstrap3/BS3/assets/css/datatables.css',
'public/css/public.style.css',
],
dest: 'public/css/built.public.css',
nonull: true,
options: {
process: false
2016-07-26 22:04:25 +02:00
}
},*/
2016-07-24 17:43:03 +02:00
/*js_pdf: {
2016-07-21 14:35:23 +02:00
src: [
'public/js/pdf_viewer.js',
'public/js/compatibility.js',
'public/js/pdfmake.min.js',
'public/js/vfs.js',
],
dest: 'public/pdf.built.js',
nonull: true
2016-07-24 17:43:03 +02:00
}*/
2016-07-21 14:35:23 +02:00
}
});
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-dump-dir');
grunt.registerTask('default', ['dump_dir', 'concat']);
};