Last active
September 23, 2015 15:42
-
-
Save gfargo/32a0275f5b989ed60931 to your computer and use it in GitHub Desktop.
Easy way to seperate out Grunt stuff to avoid massive gruntfiles
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/***************************************************** | |
Grunt'd | |
This 'plop-in' plugin was created to expedite the | |
process of adding the required files for front-end | |
development. | |
This includes template scss files and `main.js` | |
Packages: | |
-> grunt-uncss | |
-> grunt-csscss | |
-> grunt-contrib-uglify | |
-> grunt-contrib-jshint | |
-> grunt-contrib-qunit | |
-> grunt-contrib-watch | |
-> grunt-contrib-concat | |
Processes: | |
*****************************************************/ | |
module.exports = function(grunt) { | |
'use strict'; | |
require('time-grunt')(grunt); | |
// require('logfile-grunt')(grunt); | |
// var path = require('path'); // Leverage Node Path Module - https://nodejs.org/api/path.html | |
var project_configuration = require('./project'); | |
/***************************************************** | |
Grunt Init Config | |
*****************************************************/ | |
grunt.initConfig({ | |
pkg: grunt.file.readJSON('package.json'), | |
// Project Config | |
project: project_configuration, | |
/* | |
CSS | |
Sass - https://github.com/gruntjs/grunt-contrib-sass | |
CSSCSS - Used to locate dupe css selectors | |
PostCSS - Used to Automatically Insert Browser Prefixes https://github.com/nDmitry/grunt-postcss | |
UNCSS - Used to locate unused CSS rules | |
*/ | |
sass: require('../common/build/config/sass'), | |
csscss: require('../common/build/config/csscss'), | |
postcss: require('../common/build/config/postcss'), | |
uncss: require('../common/build/config/uncss'), | |
/* | |
JS | |
concat - Used to Combine Multiple Files into One | |
uglify - Transforming the code into an "unreadable" form to be used in live environments - mangles variables | |
jshint - Lint Javascript | |
qunit - Unit Testing | |
*/ | |
concat: require('../common/build/config/concat'), | |
uglify: require('../common/build/config/uglify'), | |
jshint: require('../common/build/config/jshint'), | |
qunit: require('../common/build/config/qunit'), | |
// Watch Config | |
watch: require('../common/build/config/watch.js'), | |
}); | |
/***************************************************** | |
Core Tasks | |
*****************************************************/ | |
grunt.loadNpmTasks('grunt-contrib-sass'); | |
/***************************************************** | |
Build Tasks | |
*****************************************************/ | |
require('../common/build/tasks')(grunt); | |
}; | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = { | |
paths: { | |
webroot: '/Volumes/home/gfargo/work/core/trunk/web/sites/entertainment', | |
localroot: '~/Desktop/news-breakouts', | |
sass: 'scss', | |
css: '<%= project.paths.webroot %>/lygo/ly/<%= pkg.name %>/css', | |
localjs: '<%= project.paths.localroot %>/common/js', | |
js: '<%= project.paths.webroot %>/lygo/ly/<%= pkg.name %>/js', | |
}, | |
banner: | |
'/*!\n' + | |
' * <%= pkg.name %>\n' + | |
' * <%= pkg.description %>\n' + | |
' * <%= pkg.title %>\n' + | |
' * <%= pkg.url %>\n' + | |
' * @author <%= pkg.author %>\n' + | |
' * @version <%= pkg.version %>\n' + | |
' */\n\n\n', | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// directory based instead of using specific file names | |
// http://gruntjs.com/configuring-tasks#building-the-files-object-dynamically | |
module.exports = { | |
dev: { | |
options: { | |
style: 'expanded', | |
debugInfo: true, | |
sourcemap: 'auto', // options: auto, file, inline, none | |
// compass: true | |
}, | |
files: [{ | |
expand: true, | |
cwd: '<%= project.paths.sass %>/', | |
src: [ | |
'*{.scss,.sass}', | |
'!**/vendor/*' // ignores files in lib dir | |
], | |
dest: '<%= project.paths.css %>', | |
ext: '.css' | |
}], | |
}, | |
dist: { | |
options: { | |
style: 'compressed', | |
sourcemap: 'none', | |
}, | |
files: [{ | |
expand: true, | |
cwd: '<%= project.paths.sass %>', | |
src: [ | |
'**/*.{scss,sass}', | |
'!**/vendor/*' | |
], | |
dest: '<%= project.paths.css %>', | |
ext: '.css' | |
}], | |
}, | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = function (grunt) { | |
/***************************************************** | |
Dev Tasks | |
*****************************************************/ | |
// Default Task | |
grunt.registerTask('default', [], function(){ | |
// grunt.loadNpmTasks('grunt-contrib-sass'); | |
grunt.task.run('sass:dev','js-dist'); | |
}); | |
// Watch CSS Files | |
grunt.registerTask('watch-css', [], function() { | |
grunt.loadNpmTasks('grunt-contrib-watch'); | |
// grunt.loadNpmTasks('grunt-contrib-sass'); | |
grunt.task.run('watch:styles'); | |
}); | |
// Global Watch | |
grunt.registerTask('watch', [], function() { | |
grunt.loadNpmTasks('grunt-contrib-watch'); | |
// grunt.loadNpmTasks('grunt-contrib-sass'); | |
grunt.loadNpmTasks('grunt-contrib-jshint'); | |
grunt.loadNpmTasks('grunt-contrib-concat'); | |
grunt.task.run('watch:all'); | |
}); | |
// Javascript | |
grunt.registerTask('js-dist', [], function(){ | |
grunt.loadNpmTasks('grunt-contrib-jshint'); | |
grunt.loadNpmTasks('grunt-contrib-concat'); | |
grunt.task.run('jshint:all', 'concat'); | |
}); | |
/***************************************************** | |
Dist Tasks | |
*****************************************************/ | |
// Check Files | |
grunt.registerTask('check', 'Checks for Redundancies / Autprefixes', function() { | |
// grunt.loadNpmTasks('grunt-contrib-sass'); | |
grunt.loadNpmTasks('grunt-csscss'); | |
grunt.loadNpmTasks('grunt-postcss'); | |
grunt.task.run('sass:dev','csscss:check','postcss:check'); | |
}); | |
// Final Build | |
grunt.registerTask('dist', 'Compiles all files for live environment', function() { | |
// grunt.loadNpmTasks('grunt-contrib-sass'); | |
grunt.loadNpmTasks('grunt-postcss'); | |
grunt.loadNpmTasks('grunt-contrib-jshint'); | |
grunt.task.run('sass:dist','postcss:dist', 'js-dist'); | |
}); | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = { | |
all: { | |
options: { | |
livereload: true | |
}, | |
files: [ | |
'<%= project.paths.js %>/src/*.js', | |
'<%= project.paths.sass %>/*{.scss,.sass}' | |
], | |
tasks: ['sass:dev', 'js-dist'] | |
}, | |
styles: { | |
files: '<%= project.paths.sass %>/{,*/}*.{scss,sass}', | |
tasks: ['sass:dev'], | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment