Gulp can't seem to find compass mixins - sass

I am trying out gulp as an alternative build tool to Grunt, to compile my scss to css, as I have heard it can be much faster.
I having problems doing even a basic compile of my scss files. I have tried using the gulp-sass, gulp-ruby-sass and gulp-compass plugins for gulp and I get pretty much the same error message every time:
error screen.scss (Line 2 of _grid.scss: Undefined mixin 'box-sizing'.)
So it looks like it is falling down as soon as it hits a compass mixin. I have ruby installed on my PC with compass version 1.0.0.alpha.19 and sass version 3.3.7.
Here is my gulpfile:
var gulp = require('gulp'),
compass = require('gulp-compass'),
sass = require('gulp-ruby-sass');
gulp.task('compass', function() {
gulp.src('../sass/UK/screen.scss')
.pipe(compass({
css: '../css',
sass: '../sass',
sourcemap: true,
style: 'compressed'
}))
.pipe(gulp.dest('../css/UK/screen.css'));
});
gulp.task('sass', function () {
gulp.src('../sass/UK/**/*.scss')
.pipe(sass({ style: 'compressed', sourcemap: true }))
.pipe(gulp.dest('../css/UK'));
});
Any ideas how I tell it where my copy of compass is installed? I thought it was installed globally.

There is bit of confusion around using Compass with Gulp. There are three gulp extensions: gulp-ruby-sass, gulp-compass and gulp-sass. They basically do the same thing. They compile SASS to CSS. But:
gulp-ruby-sass: Is a wrapper around command line tool: sass that comes with the language. It is written in Ruby and it is installed via gem - Ruby's package manager.
gulp-compass: Is a wrapper around command line tool: compass that comes with Compass framework. It is written in Ruby and it is also installed via gem. However, Compass is just a framework. It consists of SASS files only. All that compass command do, is setting paths to framework SASS files to sass command so that Compass dependencies are being resolved.
gulp-sass: Is a wrapper around tool: node-sass which is Node.JS binding to libsass: a C/C++ implementation of a Sass compiler.
The above answers did not work for me since I am using gulp-sass. It does not see Compass files out of the box. So first I installed compass-mixins (SASS files of Compass framework) and later I imported them with compass-importer:
import compass from 'compass-importer';
import sass from 'gulp-sass';
gulp.task('styles', function () {
return gulp.src(config.styles.src)
.pipe(sass({
importer: compass
})
.pipe(gulp.dest(config.styles.dest))
})

You right, compass should be installed globally on your system to get this work, at least easily. I recommend you to uninstall sass and compass to get something clean using
gem uninstall sass && gem uninstall compass
And then re-install them with :
gem install sass
gem install compass --pre
And after you can define a gulp task like so
gulp.task('compass', function () {
return gulp.src('../sass/UK/screen.scss')
.pipe(sass({ compass: true, sourcemap: true, style: 'compressed' }))
.pipe(gulp.dest('../css/UK/screen.css'));
});

Notice that gulp-ruby-sass has a new syntax which should look like:
gulp.task('compass', function ()
sass(../sass/UK/screen.scss, { compass: true, sourcemap: true, style: 'compressed' })
.pipe(gulp.dest('../css/UK/screen.css'));
});

Related

What am I doing wrong with npm susy and grunt?

I am trying to compile my scss files using susy, node-sass, grunt-sass
I added all these dependencies using npm install.
I am adding the setup for grunt like
sass: {
options: {
implementation: sass,
sourceMap: true
},
dist: {
options: {
style: 'expanded',
require: 'susy'
},
files: {
'app/crossbrand_us/styleguide/css/shared.css': 'app/sass/xb/widgets/advertised-offers/wdgt-advertised-offers-vehicle.scss'
}
}
},
#import "wdgt-advertised-offers-shared";
#import "node_modules/susy/sass/susy";
$wdgt-advertised-offers-vehicle-selector: ".wdgt-advertised-offers-vehicle";
#{$wdgt-advertised-offers-vehicle-selector} {
#include pad(1%);
}
but this throws an error
Fatal error: no mixin named pad
How do I fix this?
The latest versions of Susy (3.x) do not include any mixins. In order to use the old mixins, you will have to downgrade to a 2.x version of Susy (2.2.14 is the latest). Or check out the docs to get started with Susy 3.
I'm not sure if there are any other issues in the setup as well…

Can't import compass' mixins with foundation 6 and gulp

I followed the foundation tutorial to create a new project. So I compile and watch the sass files with foundatoin watch which compile my files and stream the output to the localhost but I get this error when I am trying to import compass by typing #import "compass"; :
Error in plugin 'sass'
Message:
src\assets\scss\app.scss
Error: File to import not found or unreadable: compass
Parent style sheet: C:/Users/Kevin/Dropbox/Work/Perso/2016_01_KMStudio Site/km_website/src/assets/scss/app.scss
on line 7 of src/assets/scss/app.scss
>> #import "compass";
I am really a newbie to gulp, gem and all this stuff, so I tried to add compass by running bower install compass but this doesn't help. I already installed compass with gem by running gem install compassand this doesn't fix the problem.
So I searched to modify the gulp file, but I don't know anything about it, I found this post and I tried to add .pipe(sass({ compass: true, sourcemap: true, style: 'compressed' })) into my sass pipe. And this leads me to this error:
'sass' errored after 7.62 s
[19:33:49] TypeError: Cannot read property 'isFile' of undefined
at isFile (C:\Users\Kevin\Dropbox\Work\Perso\2016_01_KMStudio Site\km_website\node_modules\gulp-load-plugins\node_modules\resolve\lib\sync.js:12:20)
at loadAsFileSync (C:\Users\Kevin\Dropbox\Work\Perso\2016_01_KMStudio Site\km_website\node_modules\gulp-load-plugins\node_modules\resolve\lib\sync.js:42:17)
at loadAsDirectorySync (C:\Users\Kevin\Dropbox\Work\Perso\2016_01_KMStudio Site\km_website\node_modules\gulp-load-plugins\node_modules\resolve\lib\sync.js:68:16)
at loadNodeModulesSync (C:\Users\Kevin\Dropbox\Work\Perso\2016_01_KMStudio Site\km_website\node_modules\gulp-load-plugins\node_modules\resolve\lib\sync.js:77:21)
at Function.module.exports [as sync] (C:\Users\Kevin\Dropbox\Work\Perso\2016_01_KMStudio Site\km_website\node_modules\gulp-load-plugins\node_modules\resolve\lib\sync.js:27:17)
at requireFn (C:\Users\Kevin\Dropbox\Work\Perso\2016_01_KMStudio Site\km_website\node_modules\gulp-load-plugins\index.js:64:25)
at Object.defineProperty.get [as sourcemaps] (C:\Users\Kevin\Dropbox\Work\Perso\2016_01_KMStudio Site\km_website\node_modules\gulp-load-plugins\index.js:103:41)
at sass (C:/Users/Kevin/Dropbox/Work/Perso/2016_01_KMStudio Site/km_website/gulpfile.babel.js:79:11)
at sass (C:/Users/Kevin/Dropbox/Work/Perso/2016_01_KMStudio Site/km_website/gulpfile.babel.js:80:11)
at sass (C:/Users/Kevin/Dropbox/Work/Perso/2016_01_KMStudio Site/km_website/gulpfile.babel.js:80:11)
Since I know nothing about gulp, streaming and sass compiling, I am wondering if someone could help me to add compass' mixins to my project. I am on Windows.

File to import not found or unreadable: compass - Gulp environment

I have set up a Gulp environment, with the intention of compiling and minifying SASS with Compass.
I have created my gulpfile with all the required tasks, all my packages are installed and running, the SASS is compiling and minifying absolutely fine, until I try and add:
#import "compass";
I have Compass installed on my Mac, and the node_package is installed, but when I run the gulp task, I get this error:
error style.scss (Line 15: File to import not found or unreadable: compass
I just can't work out what the issue is here. I have seen many questions on Stackoverflow with people who are running into the same issue, and I have tried everything.
I have tried installing the --pre version on Compass, I have tried uninstalling Compass and SASS, and reinstalling them again, but nothing.
Here are my devDependencies in my package.json:
"devDependencies": {
"gulp": "^3.8.8",
"gulp-compass": "^1.3.2",
"gulp-concat": "^2.4.1",
"gulp-minify-css": "^0.3.10",
"gulp-ruby-sass": "^0.7.1",
"gulp-uglify": "^1.0.1",
"gulp-util": "^3.0.1"
}
The styles gulp task in my gulpfile.js:
gulp.task('styles', function () {
return gulp.src('../source/sass/style.scss')
.pipe(sass({sourcemap: true, sourcemapPath: 'style.css'}))
.on('error', function (err) { console.log(err.message); })
.pipe(minifyCSS())
.pipe(gulp.dest('../public/_/'));
});
And finally the gulp task that puts everything together:
gulp.task('default',['scripts', 'styles', 'watch']);
Any help would be greatly appreciated. As I say, everything is working fine. The watch task runs and compiles my SASS and Javascript when a change has been made. It just breaks when I try and import Compass.
You've installed gulp-compass, but you're not using it in your task, so it is not supposed to work.
Since you're using gulp-ruby-sass, I think you should use its compass option and set it to true, and remove the unused gulp-compass module.
Your task would look like something like this:
gulp.task('styles', function () {
return gulp.src('../source/sass/style.scss')
.pipe(sass({ compass: true, sourcemap: true, sourcemapPath: 'style.css'}))
.on('error', function (err) { console.log(err.message) })
.pipe(minifyCSS())
.pipe(gulp.dest('../public/_/'))
})

sass compass import not in compiled css

I am running sass 3.4.2 and compass 1.0.1 and compiling compass with grunt-contrib-compass.
I am importing Zurb Foundation scss files into a master stylesheet, but a few of the imports do not appear in the compiled css. After digging deeper, it seems like if there is an error in the #import file that the error is not reported.
My grunt task config code looks like this:
compass: {
dist: {
options: {
require: [],
httpPath: '/',
http_images_path: '/assets/images',
importPath: 'public_html/assets/bower_components',
cssDir: 'public_html/assets/css',
sassDir: 'public_html/assets/_src/scss',
imagesDir: 'public_html/assets/images',
javascriptsDir: 'public_html/assets/_src/js',
outputStyle: 'compressed',
noLineComments: true
}
},
This issue was related to the #export mixing being broken. It can be fixed by rolling back to previous version of sass and compass or by editing the foundation source code.
Please see these fixes:
http://foundation.zurb.com/forum/posts/18624-foundation-5-and-compass-10
https://github.com/zurb/foundation/issues/5636
https://github.com/zurb/foundation/pull/5632/files

gulp isn't noticing sass/compass extension imports / bundler

This is my first time using gulp. Up until now I've always used bundle exec compass watch to compile my scss files.
I'm getting the following error in the command prompt when I run gulp:
Syntax error: file to import not found or unreadable: singularitygs
load paths: ... .. on line 14 of C:\<my path>\scss\partials\0_global\_base.scss
events.js:72 throw er; /unhandled 'error' event
<-[36mgulp-ruby-sass<-[39m] Error in plugin '<-[36mgulp-ruby-sass<-[39m':
..
..
at ChildProcess. <anonamous> c:\<my path>\node_modules\gulp-ruby-by-sass\index.js:100:25)
at ChlidProcess.EventEmitter.emit(events.js:98:17)
at maybeClose(child_process.js:743:16)
at Process.ChildProcess._handle.onexit (child_process.js:810:5)
On my _base.scss file, it's seeing:
#import 'singularitygs';
#import 'toolkit';
#import 'sassy-buttons';
All of these extensions are declared in my config.rb file and in my gemfile and work fine when I run bundle exec compass watch
If I comment out singularitygs, I get the same error for toolkit and sassy-buttons if I comment out toolkit. If I comment all of them out, it throws me an error because it doesn't notice variables that toolkit uses.
My gulpfile.js includes the following:
var gulp = require('gulp'),
sass = require('gulp-ruby-sass'),
autoprefixer = require('gulp-autoprefixer'),
minifycss = require('gulp-minify-css'),
jshint = require('gulp-jshint'),
uglify = require('gulp-uglify'),
imagemin = require('gulp-imagemin'),
rename = require('gulp-rename'),
clean = require('gulp-clean'),
concat = require('gulp-concat'),
notify = require('gulp-notify'),
cache = require('gulp-cache'),
livereload = require('gulp-livereload')
compass = require('gulp-compass');
gulp.task('styles',function(){
return gulp.src('scss/*.scss')
.pipe(sass({style: 'expanded', bundleExec:true}))
.pipe(compass({config_file: 'config.rb', css:'stylesheets', sass:'scss', font:'stylesheets/fonts', require: ['singularitygs', 'toolkit', 'sassy-buttons'], bundle_exec:true}))
.pipe(autoprefixer('last 2 version', 'safari 5', 'ie 8', 'ie 9', 'opera 12.1', 'ios 6', 'android 4'))
.pipe(gulp.dest('dist/assets/css'))
.pipe(rename({suffix: '.min'}))
.pipe(minifycss())
.pipe(gulp.dest('dist/assets/css'))
.pipe(notify({message: 'Styles task complete'}));
});
I've been racking my brain at this for over 4 hours and having searching elsewhere for what it could with zero luck. I'm surely not the first person to not have bundled dependencies not work with gulp.
All of my gems are up to date and everything works fine when I compile with bundle exec compass watch. I've also tried reinstalling several different gulp packages like:
npm install gulp-ruby-sass
npm install gulp-compass
I'm also using WAMP and windows 8,.. if that matters at all.
Thanks for your time.
Please try commented the notify line.
ref https://github.com/appleboy/gulp-compass/issues/40
gulp-ruby-sass was messing things up, for some reason. Seems like more people would have ran into this problem before me though.
I commented out sass = require('gulp-ruby-sass'), and .pipe(sass({style: 'expanded', bundleExec:true})) and it worked.

Resources