Skip to content

Instantly share code, notes, and snippets.

@DanyelMorales
Created June 25, 2018 17:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DanyelMorales/4edb0618339914d1ff455cca03c9b879 to your computer and use it in GitHub Desktop.
Save DanyelMorales/4edb0618339914d1ff455cca03c9b879 to your computer and use it in GitHub Desktop.
Precompile scss to css
var root = "./assets";
var publicPath = "./public/assets";
var cssPath = publicPath + "/css/";
var jsPath = publicPath + "/js/";
var htmlDevelopmentFiles = ['./app/views/**/*.html'];
var sass = {
source: root + '/css/',
dest: cssPath,
pattern: "**/*.scss"
};
var livereload = {
host: 'localhost',
port: 10766
};
module.exports = function (grunt) {
require('load-grunt-tasks')(grunt);
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
sass: {
dist: {
options: {
sourceMap: true,
style: "compressed"
},
files: [{
expand: true,
flatten: true,
cwd: sass.source,
src: ["!**/*.ignore.scss", sass.pattern],
dest: sass.dest,
ext: '.min.css'
}],
}
},
watch: {
sass: {
files: [sass.source + sass.pattern, "!**/*.ignore.scss"],
tasks: ['pre-compile'],
options: {
spawn: true
},
},
livereload: {
files: [sass.source + sass.pattern, htmlDevelopmentFiles],
options: {
livereload: livereload,
spawn: true
}
}
}
});
grunt.registerTask('default', ['watch']);
grunt.registerTask('production', ['pre-compile']);
grunt.registerTask('pre-compile', ['sass']);;
grunt.loadNpmTasks('grunt-contrib-sass');
grunt.loadNpmTasks('grunt-contrib-watch');
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment