Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Two files exported when trying to rename filename. #115

Open
sunglee opened this issue Dec 14, 2015 · 3 comments
Open

Two files exported when trying to rename filename. #115

sunglee opened this issue Dec 14, 2015 · 3 comments

Comments

@sunglee
Copy link

sunglee commented Dec 14, 2015

Hi,

Anyone tried to rename output file to some_style.min.css?
I am trying to change the output file name with the following task:

gulp.task('compass', false, function () {
  return gulp.src([SASS_PATH + '/**/*.scss')
    .pipe(changed(DEST_PATH, {extension: '.min.css'}))
    .pipe(compass({
      config_file: 'config.rb',
      css: DEST_PATH,
      sass: SASS_PATH,
      style: 'compressed',
      debug: false,
      require: ['susy'],
    }))
    .pipe($.autoprefixer())
    .pipe($.rename({
      suffix: ".min"
    }))
    .pipe(gulp.dest(DEST_PATH))
    .pipe(reload({stream: true}));
});

When I run the above task, it exports some_style.css as well as some_style.min.css.
How can I export only some_style.min.css file?

@hammat
Copy link

hammat commented Mar 23, 2016

Same case for me, adding a suffix creates both with and without suffix files.

Have you found a way to handle this ?

@ladytellur
Copy link

ladytellur commented Aug 2, 2016

It's actually not an issue of gulp-compass but Compass itself.

You could rename files in ruby callback in config_file (config.rb) by placing

require "fileutils"

on_stylesheet_saved do |file|
  if File.exists?(file)
    filename = File.basename(file, File.extname(file))
    File.rename(file, css_dir + "/" + filename + ".min" + File.extname(file))
  end
end

http://h3r2on.com/2013/05/17/rename-css-on-compile.html

be careful with paths (css_dir), it should be relative to work that way.
Also .pipe tasks after such renaming may not executes

@ladytellur
Copy link

The best solution I found is Delete files in a pipeline to delete unneeded some_style.css file after renaming into some_style.min.css

the result task could be

var del = require('del');
var vinylPaths = require('vinyl-paths');

gulp.task('compass', false, function () {
  return gulp.src([SASS_PATH + '/**/*.scss')
    .pipe(changed(DEST_PATH, {extension: '.min.css'}))
    .pipe(compass({
      config_file: 'config.rb',
      css: DEST_PATH,
      sass: SASS_PATH,
      style: 'compressed',
      debug: false,
      require: ['susy'],
    }))
    .pipe($.autoprefixer())
    .pipe(vinylPaths(del))
    .pipe($.rename({
      suffix: ".min"
    }))
    .pipe(gulp.dest(DEST_PATH))
    .pipe(reload({stream: true}));
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants