Skip to content

Instantly share code, notes, and snippets.

@spektraldevelopment
Created November 2, 2015 16:24
Show Gist options
  • Save spektraldevelopment/46e8fb475702fcf78caf to your computer and use it in GitHub Desktop.
Save spektraldevelopment/46e8fb475702fcf78caf to your computer and use it in GitHub Desktop.
Node: Gruntfile and package
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"]
);
};
{
"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