Created
June 25, 2018 17:14
-
-
Save DanyelMorales/4edb0618339914d1ff455cca03c9b879 to your computer and use it in GitHub Desktop.
Precompile scss to 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
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