Giter VIP home page Giter VIP logo

Comments (14)

jannisg avatar jannisg commented on May 29, 2024 1

Aha! Thanks for the pointer, I managed to work around this oddity for now using 2 separate tasks as follows.

In task 1, I purely compile the scss to css using compass and setting the compass css_dir to a .tmp folder.
Then in task 2, I gulp.src the .tmp files and work with them, writing the output back into the actual assets/css folder.

Not particular nice or clean, but it does seem to work for now.

// Work with our SCSS files.
gulp.task('compass', function() {
  gulp
    .src('assets/scss/**.scss')
    .pipe( tasks.compass( { config_file: './config.rb' } ) )
    .pipe( gulp.dest('.tmp') );
});

// Add vendor prefixes to our generated CSS file.
gulp.task('autoprefixer', function() {
  gulp
    .src('.tmp/**/*.css')
    .pipe( tasks.autoprefixer( 'last 2 versions', 'ie 8' ) )
    .pipe( gulp.dest('.') )
    .pipe( tasks.livereload(server) )
    .pipe( tasks.filesize() );
});

And then in the livereload server task:

    gulp.watch('assets/scss/**',            function(e) { gulp.run('compass'); });
    gulp.watch('.tmp/**/*.css',             function(e) { gulp.run('autoprefixer'); });

from gulp-compass.

yocontra avatar yocontra commented on May 29, 2024

The code for this module is confusing... The file object is never actually being manipulated - it runs compass on the file contents but doesn't use the output at all. Very strange.

from gulp-compass.

yocontra avatar yocontra commented on May 29, 2024

If this is writing to a tmp folder and not modifying the files in the stream its violating the plugin guidelines

from gulp-compass.

appleboy avatar appleboy commented on May 29, 2024

Hi @jannisg,

Please update to version 1.0.2 and try it again.

Thanks.

from gulp-compass.

yocontra avatar yocontra commented on May 29, 2024

@appleboy Is there any way to prevent this from writing to disk? Plugins should not be writing this to disk - they should only be modifying the contents in memory and passing them along. The actual disk write happens in gulp.dest

from gulp-compass.

appleboy avatar appleboy commented on May 29, 2024

@contra I try to find another way to prevent this from writing to disk, but the compass command is not support with displaying CSS result directly.

I will try to find another approach. Thanks.

from gulp-compass.

yocontra avatar yocontra commented on May 29, 2024

@appleboy I know it's not your fault nathggns/node-compass#29

from gulp-compass.

appleboy avatar appleboy commented on May 29, 2024

@contra I create issue on compass project. ref Compass/compass/issues/1499

from gulp-compass.

sindresorhus avatar sindresorhus commented on May 29, 2024

This is exactly why I didn't create a gulp task for Compass. Compass is inherently "designed" as an awful (slow) config mess. I predict nothing will be done about this upstream. I created grunt-contrib-compass and still regret it.

from gulp-compass.

dmp42 avatar dmp42 commented on May 29, 2024

@appleboy I'm confused about what the remaining issues are here (apart from the suckiness of compass itself).

Is there a test-case I could use to reproduce the problem?
Of master now the following is wfm (which I think fix the O.P. problem?):

gulp.src('src/**/*.{scss,css}')
  .pipe(compass({
      style: 'nested',
      sass: 'src',
      comments: true,
      logging: true
    }
  ))
  .pipe(map(function(file, cb){
    console.warn("This is triggered ->", file.path);
    console.warn(file.contents.toString('utf8'));
    cb(null, file);
  }));

Thanks!

from gulp-compass.

taai avatar taai commented on May 29, 2024

I have got an idea!

Currently the Compass does not provide an option to return the compiled CSS instead of writing it into the file...

The work-around:

  1. Create a temporary directory (preferably in system's temp directory)
  2. Force compass to build CSS there
  3. Read the compiled CSS files into memory
  4. Delete temporary files
  5. Pipe files from memory

By the way, can we use compass watch to increase speed of compilation process (for watch tasks?

from gulp-compass.

sindresorhus avatar sindresorhus commented on May 29, 2024

@taai that's what gulp-ruby-sass does.

from gulp-compass.

taai avatar taai commented on May 29, 2024

@sindresorhus Great! I would like that with Compass too. By the way, can you tell me the difference between compass and sass --compass? The compass with all features is being used anyway, right? Or just the syntax?

from gulp-compass.

sindresorhus avatar sindresorhus commented on May 29, 2024

--compass flag enables the compass imports, but none of the conventions and settings.

from gulp-compass.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.