Created
November 2, 2015 16:24
-
-
Save spektraldevelopment/46e8fb475702fcf78caf to your computer and use it in GitHub Desktop.
Node: Gruntfile and package
This file contains hidden or 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) { | |
// configure the tasks | |
grunt.initConfig({ | |
pkg: grunt.file.readJSON("package.json"), | |
dot: true, | |
clean: { | |
sass: ["files/to/clean", "other/files/to/clean"] | |
}, | |
watch: { | |
sass: { | |
files: ['**/*.scss', '**/**/*.scss'], | |
tasks: ['re-sass'], | |
options: { | |
interrupt: true | |
}, | |
} | |
}, | |
sass: { | |
dist: { | |
files: { | |
'path/to.css': 'path/to.scss', | |
} | |
} | |
}, | |
unused: { | |
options: { | |
reference: grunt.option('ref'), | |
directory: ['**/*.html'], | |
remove: false // set to true to delete unused files from project | |
} | |
}, | |
uncss: { | |
dist: { | |
files: { | |
'css/base-tidy.css': ['index.html'] | |
} | |
} | |
} | |
}); | |
//EVENTS | |
grunt.event.on('watch', function(action, filepath, target) { | |
grunt.log.writeln(target + ': ' + filepath + ' has ' + action); | |
}); | |
//LOAD TASKS | |
//Wipes the opted folder clean of files | |
grunt.loadNpmTasks("grunt-contrib-clean"); | |
//Watch for changes | |
grunt.loadNpmTasks('grunt-contrib-watch'); | |
//Compile sass | |
grunt.loadNpmTasks('grunt-contrib-sass'); | |
//Checks for unused files | |
grunt.loadNpmTasks('grunt-unused'); | |
//Cleans up unused css | |
grunt.loadNpmTasks('grunt-uncss'); | |
//REGISTER TASKS | |
//Default - command: grunt default | |
grunt.registerTask( | |
"default", | |
"Watch and reload sass files.", ["clean", "sass", "watch"] | |
); | |
grunt.registerTask( | |
"re-sass", | |
"Clean old css and re-compile sass.", ["clean", "sass"] | |
); | |
}; |
This file contains hidden or 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
{ | |
"name": "", | |
"version": "0.0.1", | |
"author": "Spektral", | |
"dependencies": { | |
"grunt": "0.x.x" | |
}, | |
"engine": "node >= 0.10.x", | |
"devDependencies": { | |
"grunt-contrib-clean": "^0.6.0", | |
"grunt-contrib-sass": "^0.9.2", | |
"grunt-contrib-watch": "^0.6.1", | |
"grunt-uncss": "^0.4.3", | |
"grunt-unused": "^0.2.0" | |
}, | |
"repository": { | |
"type": "git", | |
"url": "" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment