Commit 986beebb authored by Ryan Dee's avatar Ryan Dee
Browse files

Update 4.1- and 5.0-specific tasks in Gruntfile

- Restore 4.1-specific Less tasks in Gruntfile
- Append ‘-5.0’ to CSS files compiled from Sass
parent 50719aea
......@@ -3,6 +3,8 @@ var fs = require('fs');
const sass = require('node-sass');
module.exports = function (grunt) {
var lessDir = 'www/less';
var lessVendorDir = lessDir + '/lib';
var sassDir = 'www/scss';
// var sassVendorDir = sassDir + '/mixins';
var cssDir = 'www/css';
......@@ -17,6 +19,16 @@ module.exports = function (grunt) {
jsDir + '/search.js',
];
var wdnMixinLibBaseUrl = 'https://raw.githubusercontent.com/unl/wdntemplates/4.1/wdn/templates_4.1/less/_mixins/';
var wdnMixins = [
'breakpoints.less',
'colors.less',
'fonts.less',
];
var allMixinsExist = every(wdnMixins, function(value) {
return fs.existsSync(lessVendorDir + '/' + value);
});
// TODO: Import DCF and UNLedu 5.0 mixins and variables
// var dcfMixinLibBaseUrl = 'https://raw.githubusercontent.com/d-c-n/dcf/master/assets/dist/scss/mixins/';
// var dcfMixins = [
......@@ -29,31 +41,55 @@ module.exports = function (grunt) {
// return fs.existsSync(sassVendorDir + '/' + value);
// });
var lessFiles = {};
cssFiles.forEach(function(file) {
lessFiles[cssDir + '/' + file + '.css'] = lessDir + '/' + file + '.less';
});
var sassFiles = {};
cssFiles.forEach(function(file) {
sassFiles[cssDir + '/' + file + '.css'] = sassDir + '/' + file + '.scss';
sassFiles[cssDir + '/' + file + '-5.0.css'] = sassDir + '/' + file + '.scss';
});
var builtJsFiles = {};
builtJsFiles[jsDir + '/search.min.js'] = jsFiles;
// var autoprefixPlugin = new (require('less-plugin-autoprefix'))({browsers: ["last 2 versions"]});
// var cleanCssPlugin = new (require('less-plugin-clean-css'))();
var autoprefixPlugin = new (require('less-plugin-autoprefix'))({browsers: ["last 2 versions"]});
var cleanCssPlugin = new (require('less-plugin-clean-css'))();
// load all grunt tasks matching the ['grunt-*', '@*/grunt-*'] patterns
require('load-grunt-tasks')(grunt);
grunt.initConfig({
// 'curl-dir': {
'curl-dir': {
'less-libs': {
src: wdnMixins.map(function(file) {
return wdnMixinLibBaseUrl + file;
}),
dest: lessVendorDir
}
// 'dcf-mixins': {
// src: dcfMixins.map(function(file) {
// return dcfMixinLibBaseUrl + file;
// }),
// dest: sassVendorDir
// }
// // TODO: add UNLedu 5.0 mixins
// },
// TODO: add UNLedu 5.0 mixins
},
less: {
all: {
files: lessFiles,
options: {
paths: [lessDir],
plugins: [
autoprefixPlugin,
cleanCssPlugin
]
}
}
},
sass: {
all: {
......@@ -121,12 +157,17 @@ module.exports = function (grunt) {
},
clean: {
lessCss: Object.keys(lessFiles).concat(lessVendorDir),
// css: Object.keys(sassFiles).concat(sassVendorDir),
css: Object.keys(sassFiles),
sassCss: Object.keys(sassFiles),
js: Object.keys(builtJsFiles).concat(jsDir + '/**/*.map')
},
watch: {
less: {
files: lessDir + '/**/*.less',
tasks: ['less']
},
sass: {
files: sassDir + '/**/*.scss',
tasks: ['sass', 'postcss']
......@@ -138,9 +179,9 @@ module.exports = function (grunt) {
// establish grunt default
var defaultTasks = ['sass', 'postcss', 'uglify', 'requirejs'];
var localTasks = defaultTasks.slice();
// if (!allMixinsExist) {
// defaultTasks.unshift('curl-dir');
// }
if (!allMixinsExist) {
defaultTasks.unshift('curl-dir');
}
grunt.registerTask('default', defaultTasks);
grunt.registerTask('all-local', localTasks);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment