blue-twilight/Gruntfile.js

127 lines
3.9 KiB
JavaScript

/*
This Gruntfile downloads the necessary CSS and JS includes (Bootstrap, etc.) and creates a combined file ready for
deployment with the application.
Available tasks:
- build-debug: Builds the minified CSS and JS files
*/
module.exports = function(grunt)
{
var download_url = 'https://cdn.andysh.uk/';
const sass = require('node-sass');
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-curl');
grunt.loadNpmTasks('grunt-dart-sass');
grunt.loadNpmTasks('grunt-exec');
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
clean: {
build_css: [
// Clean the build folder - downloaded files
'build/css',
// Clean the resources folder - compiled SASS files
'resources/css'
],
build_js: [
'build/js',
],
output: [
'public/css',
'public/js'
]
},
concat: {
// Concatenate all third-party stylesheets into blue-twilight.css
bt_css: {
src: [
'build/css/*.css',
'resources/css/*.css'
],
dest: 'public/css/blue-twilight.css'
},
// Concatenate all third-party and application Javascripts into blue-twilight.js
bt_js: {
src: [
'build/js/*.js',
'resources/js/*.js',
],
dest: 'public/js/blue-twilight.js'
},
},
curl: {
/* These elements are sorted according to the order we desire them to be loaded when concatenated */
/** CSS **/
bootstrap_css: {
src: download_url + 'bootstrap/4.4.1/css/bootstrap.css',
dest: 'build/css/01-bootstrap.css'
},
/** JS **/
jquery: {
src: download_url + 'jquery/3.4.1/jquery.js',
dest: 'build/js/01-jquery.js'
},
bootstrap_js: {
src: download_url + 'bootstrap/4.4.1/js/bootstrap.bundle.js',
dest: 'build/js/02-bootstrap.js'
},
bootbox_js: {
src: download_url + 'bootbox/5.3.3/bootbox.all.js',
dest: 'build/js/03-bootbox.js'
},
font_awesome_js: {
src: download_url + 'font-awesome/5.12.0/js/all.js',
dest: 'build/js/04-fontawesome.js'
},
vuejs: {
src: download_url + 'vuejs/2.6.11/vue.js',
dest: 'build/js/05-vuejs.js'
},
},
'dart-sass': {
bt_sass: {
options: {
sourceMap: false
},
files: [{
expand: true,
cwd: 'resources/sass/',
src: ['*.scss'],
dest: 'resources/css/',
ext: '.css'
}]
},
}
});
// Register our tasks
grunt.registerTask('build-css-debug', [
// Download third-party stylesheets
'curl:bootstrap_css',
// SASS our own CSS
'dart-sass:bt_sass',
// Create our blue-twilight.css
'concat:bt_css'
]);
grunt.registerTask('build-js-debug', [
// Download third-party Javascripts
'curl:jquery',
'curl:bootstrap_js',
'curl:bootbox_js',
'curl:font_awesome_js',
'curl:vuejs',
// Create our blue-twilight.js
'concat:bt_js'
]);
// Shortcut tasks for the ones above
grunt.registerTask('clean-all', ['clean:build_css', 'clean:build_js', 'clean:output']);
grunt.registerTask('build-debug', ['clean-all', 'build-css-debug', 'build-js-debug']);
};