Skip to content

Instantly share code, notes, and snippets.

@sjungling
Created August 21, 2013 20:11
Show Gist options
  • Save sjungling/6299571 to your computer and use it in GitHub Desktop.
Save sjungling/6299571 to your computer and use it in GitHub Desktop.
module.exports = function(grunt) {
// Command Line Arguments
var currentSite = grunt.option('site') || 'build',
currentNicheSite = grunt.option('nicheSite') || 'faucetdirect';
/**
* BUILD - Global var for centralizing helper functions and stanard configs
* @type {Object}
*/
var BUILD = {
javascript: {
files: [
'themes/**/scripts/**/*.js',
'!themes/build/scripts/vendor/**',
'!themes/niche/scripts/vendor/**',
'!themes/**/scripts/s_code.js',
'!themes/**/scripts/**/mbox*.js',
'!themes/**/scripts/**/tv.js'
]
},
uglify: {
options: {
files: function(srcDir) {
var filesAry = [];
var results = {};
filesAry.push(srcDir);
filesAry = grunt.file.expand(filesAry);
filesAry.forEach(function(file) {
results[file] = [file];
});
return results;
}
}
}
};
// Project configuration.
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
jshint: {
files: BUILD.javascript.files,
options: {
jshintrc: ".jshintrc",
force: true
}
},
compass: {
build: {
options: {
config: "themes/build/assetnodes/build.com/config.rb",
quiet: false
}
},
niche: {
options: {
config: "themes/niche/assetnodes/" + currentNicheSite + ".com/config.rb",
quite: false
}
},
cleaner: {
options: {
clean: true
}
}
},
watch: {
build_sass: {
files: ['themes/build/sass/**/*.{scss,sass}'],
tasks: ['compass:build']
},
niche_sass: {
files: ['themes/niche/sass/**/*.{scss,sass}'],
tasks: ['replacer:theme', 'compass:niche']
},
javascript: {
files: BUILD.javascript.files,
tasks: ['jsbeautifier:default']
},
grunt: {
files: ["Gruntfile.js"],
tasks: ['jsbeautifier:grunt']
},
assets: {
files: ['assets/assets.json'],
tasks: ['jsbeautifier:assets']
}
},
replacer: {
theme: {
options: {
replace: {
'@DSN@': currentNicheSite || 'faucetdirect'
}
},
files: [{
src: ['config/samples/_theme.scss_sample'],
dest: 'themes/niche/sass/_theme.scss'
}]
}
},
jsbeautifier: {
options: {
config: '.jsbeautifyrc'
},
"default": {
src: BUILD.javascript.files
},
"grunt": {
src: ['Gruntfile.js', 'package.json']
},
"assets": {
src: ['assets/assets.json']
}
},
shell: {
clean: {
command: 'rm -rf node_modules;npm install;',
options: {
stdout: true,
stderr: true
}
}
}
});
grunt.loadNpmTasks('grunt-contrib-compass');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-jsbeautifier');
grunt.loadNpmTasks('grunt-replacer');
grunt.loadNpmTasks('grunt-shell');
// Default task.
grunt.registerTask('default', 'Default task as called by ant', ['clean', 'watch']);
grunt.registerTask('clean', "Clean sass-cache", ['compass:cleaner']);
grunt.registerTask('compile', function() {
grunt.log.writeln("CurrentSite: " + currentSite);
grunt.task.run("compass:cleaner");
if (currentSite !== "build") {
grunt.task.run("replacer");
grunt.task.run('compass:niche');
} else {
grunt.task.run('compass:build');
}
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment