Created
July 24, 2015 00:19
-
-
Save neoGeneva/1d58fb6f6db140ad73f1 to your computer and use it in GitHub Desktop.
SCSS compilation on save for VS2015 (for scss files under /Content/)
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
/// <binding ProjectOpened='watch' /> | |
module.exports = function (grunt) { | |
grunt.initConfig({ | |
bower: { | |
install: { | |
options: { | |
targetDir: "lib", | |
layout: "byComponent", | |
cleanTargetDir: false | |
} | |
} | |
}, | |
sass: { | |
targeted: { | |
files: {} | |
} | |
}, | |
cssmin: { | |
targeted: { | |
options: { | |
report: "min", | |
sourceMap: true | |
}, | |
files: {} | |
} | |
}, | |
watch: { | |
sass: { | |
files: ["Content/**/*.scss"], | |
tasks: ["sass:targeted", "cssmin:targeted"], | |
options: { | |
spawn: false | |
} | |
} | |
} | |
}); | |
grunt.registerTask("default", []); | |
grunt.loadNpmTasks("grunt-bower-task"); | |
grunt.loadNpmTasks("grunt-contrib-sass"); | |
grunt.loadNpmTasks("grunt-contrib-cssmin"); | |
grunt.loadNpmTasks("grunt-contrib-watch"); | |
grunt.event.on("watch", function (action, filepath) { | |
var cssminFiles = {}; | |
cssminFiles[filepath.replace(/\.scss$/, ".min.css")] = filepath.replace(/\.scss$/, ".css"); | |
var sassFiles = {}; | |
sassFiles[filepath.replace(/\.scss$/, ".css")] = filepath; | |
grunt.config("sass.targeted.files", sassFiles); | |
grunt.config("cssmin.targeted.files", cssminFiles); | |
}); | |
}; |
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
{ | |
"name": "package", | |
"version": "1.0.0", | |
"private": true, | |
"devDependencies": { | |
"grunt": "0.4.5", | |
"grunt-bower-task": "0.4.0", | |
"grunt-contrib-cssmin": "0.12.3", | |
"grunt-contrib-sass": "0.9.2", | |
"grunt-contrib-watch": "0.6.1" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment