A
A
Alexander2015-08-23 19:29:49
gulp.js
Alexander, 2015-08-23 19:29:49

How to set up gulp-compass?

Hello. There is such a problem. I use Gulp+Jade+Sass. Today I decided to install a compass. I don’t know about you, but in my opinion there is a benefit from it, well, or at least there is no harm. So after reading the manuals, I tried to file it all in gulp. It seems to work, but there are a few nuances. I'll start with the sources:
There is such a gupp.js file

var gulp = require('gulp'),
    jade = require('gulp-jade'), // Плагин для Jade
    livereload = require('gulp-livereload'), // Livereload для Gulp   
    imagemin = require('gulp-imagemin'), // Минификация изображений
    sass = require('gulp-sass'),    
    connect = require('gulp-connect'),// Сервер
    uncss = require('gulp-uncss'),
    compass = require('gulp-compass'),   
    concat = require('gulp-concat'); // Склейка файлов    ;

gulp.task('connect', function () {
    connect.server({
        root: 'public/',
        livereload:true
    });
});
// Собираем html из Jade
gulp.task('jade', function() {
    gulp.src(['app/templates/pages/*.jade', '!app/templates/lib/_*.jade'])
    .pipe(jade({
      pretty: true
    }))
    .pipe(gulp.dest('public/')) // Записываем собранные файлы
    .pipe(connect.reload()); // даем команду на перезагрузку страницы
});
/* Собираем sass
gulp.task('sass', function(){
    gulp.src(['./app/styles/*.sass', '!app/styles/lib/_*.sass'])
    .pipe(sass())
    .pipe(gulp.dest('public/css/'))
    .pipe(connect.reload());
});*/
gulp.task('compass', function() {
  gulp.src(['./app/styles/*.sass', '!app/styles/lib/_*.sass'])
    .pipe(compass({
        config_file: './config.rb',
            sass: './app/styles/',            
        }))
    .pipe(gulp.dest('public/css/'))
    .pipe(connect.reload());
});
// Собираем JS
gulp.task('js', function() {
    gulp.src(['app/scripts/**/*.js', '!./app/scripts/vendor/**/*.js'])
        .pipe(concat('main.js')) // Собираем все JS, кроме тех которые находятся в ./assets/js/vendor/**
        .pipe(gulp.dest('public/js'))
        .pipe(connect.reload()); // даем команду на перезагрузку страницы
});
// Копируем и минимизируем изображения
gulp.task('images', function() {
    gulp.src('app/images/**/*')
        .pipe(imagemin())
        .pipe(gulp.dest('public/img'))
        .pipe(connect.reload()); // даем команду на перезагрузку страницы
});
gulp.task('watch', function () {
    gulp.watch('app/**/*.jade', ['jade'])
    gulp.watch('app/styles/**/*.sass', ['compass'])
    gulp.watch('app/images/**/*', ['images'])
    gulp.watch('app/scripts/**/*.js', ['js']);    
});

gulp.task('default', ['connect', 'jade', 'compass', 'js', 'images', 'watch']);

and config.rb
http_path = "/"
css_dir = "css"
sass_dir = "sass"
images_dir = "img"
output_style = :compact
relative_assets = true
line_comments = false
preferred_syntax = :sass

93594802c0b0406ca17d47e0f5bbb401.JPG
The first nuance is that an extra css folder is created with the common.css file. This can be seen from the directory tree. It's not hard to remove, but it shouldn't be. Here is the question how to fix it.
The second caveat is that after installing the compass, a bunch of goodies appeared. But something broke. Namely, there is a mixins.sass file. So now if you use mixins from it, it gives you the following error:
46779369f6c5416d9111bfdb17574218.JPG
Tell me how to organize and configure all this ???

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question