Created
June 20, 2016 01:56
-
-
Save Grawl/64c9963fadb572dea94c9723fca108d3 to your computer and use it in GitHub Desktop.
Laravel Elixir + PostCSS + Sass (or Stylus or Less or other preprocessor)
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
// Task to compile styles with PostCSS | |
elixir.extend('processStyles', options=> { | |
var name = 'processStyles' | |
var sourcemaps = require('gulp-sourcemaps') | |
var err = e => { | |
console.log(require('gulp-util').colors.bgRed('PostCSS - Error')) | |
console.log(e.message) | |
} | |
var notification = require('laravel-elixir/Notification') | |
new elixir.Task(name, ()=> { | |
return gulp.src(options.src, {cwd: config.assetsPath}) | |
.pipe(gulpif(config.sourcemaps, sourcemaps.init())) | |
.pipe(require('gulp-sass')().on('error', err)) | |
.pipe(require('gulp-postcss')( | |
[ | |
require('postcss-devtools'), | |
require('autoprefixer'), | |
require('postcss-axis'), | |
require('postcss-short'), | |
require('postcss-import') | |
] | |
).on('error', err)) | |
.pipe(gulpif(config.sourcemaps, sourcemaps.write('.'))) | |
.pipe(gulp.dest(`${config.publicPath}/${config.css.outputFolder}`)) | |
.pipe(new notification().message(name + ' Compiled!')) | |
}) | |
.watch(config.assetsPath + '/' + options.watch) | |
.ignore(config.css.outputFolder + '/**/*.css') // not sure about this | |
}) | |
elixir(mix=> { | |
mix.processStyles({ | |
src: [ | |
'!sass/_*', | |
'sass/*.{scss,sass}' | |
], | |
watch: 'sass/**/*.{scss,sass}' | |
}) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment