Git Product home page Git Product logo

Comments (17)

yocontra avatar yocontra commented on May 31, 2024

This seems like a good case for gulp-rename. gulp.dest is specifically for folders - we used to have a .file output but that was removed

Proposed:

gulp.task('minifycss', function() {
    gulp.src('./dist/assets/css/main.css')
        .pipe(minifycss())
        .pipe(rename('main.min.css'))
        .pipe(gulp.dest('./dist/assets/css/'));
});

This also gives me an idea for a gulp-extrename plugin that changes the extension of any file passed through

from gulp.

hparra avatar hparra commented on May 31, 2024

A rename function would be in the piping spirit, but it should be more powerful than the proposed. It should offer all the globbing business addressed by #6 and #7.

I added a filename function to gulp-cli. I'm not crazy about that pattern. Would prefer some sort of smart string.

from gulp.

yocontra avatar yocontra commented on May 31, 2024

@hparra Would you mind renaming that to gulp-spawn? I was planning on using gulp-cli to split out that section of code soon

For the rename plugin you could have a few different ways. String for simple rename, object like {extension: '.min.css'} to just change an extension, or a function that takes in the existing name and returns the new name. I can't think of any cases that wouldn't be covered by those.

Other plugins could use this rename plugin to rename files, change file extensions, etc. by piping their existing output through it

from gulp.

hparra avatar hparra commented on May 31, 2024

@contra Yeah. That's exactly the way it should work - takes hash of helpful params like "extension", "prefix", "suffix", or a function to roll your own deal, e.g. regex, etc.

RE: gulp-cli. I unpublished it. You should probably go ahead and sit on entry.

from gulp.

yocontra avatar yocontra commented on May 31, 2024

@hparra I got chastised by isaacs for camping a plugin before while I was working on the code. I'll just hope nobody is a dick and takes it.

from gulp.

yocontra avatar yocontra commented on May 31, 2024

Also @hparra feel free to make gulp-rename yourself if you want! The idea is pretty straightforward and there is already code for renaming extensions and whatnot in gulp-util

from gulp.

markgoodyear avatar markgoodyear commented on May 31, 2024

@contra @hparra I like the idea of rename, sounds just what I'm after. Changing the extension also works too, might actually be a better solution for specifying .min.css, saves from re-specifying the main file name.

from gulp.

yocontra avatar yocontra commented on May 31, 2024

Putting out a bounty of $5 to anyone who wants to make gulp-rename

from gulp.

hparra avatar hparra commented on May 31, 2024

Sorry, I was going to do this since I already did that filename business, but I got side-tracked just building the yeoman generator.

Proposal: it accepts a string for explicit rename, or a hash with options for common operations (prefix, suffix, extension) relative to the original filename, or a custom function.

from gulp.

yocontra avatar yocontra commented on May 31, 2024

@hparra Exactly what I had in mind

from gulp.

hparra avatar hparra commented on May 31, 2024

@contra Me too. Will get to it later tonight.

from gulp.

yocontra avatar yocontra commented on May 31, 2024

#37

from gulp.

hparra avatar hparra commented on May 31, 2024

@markgoodyear Released as gulp-rename.

@contra I guess you can close this!

from gulp.

markgoodyear avatar markgoodyear commented on May 31, 2024

@hparra Tested, and works great. I use the same method for minifying JS, so the .pipe(rename({suffix: '.min'})) is perfect for both cases — no need to worry about re-specifying file name/type. Good work! 👍

from gulp.

yocontra avatar yocontra commented on May 31, 2024

Nice! @hparra DM me your gmail so I can send you a wallet payment

from gulp.

jurchiks avatar jurchiks commented on May 31, 2024

This really should be built-in functionality... It is extremely common to output files in the format name.min.ext.

from gulp.

phated avatar phated commented on May 31, 2024

No, it should not, use gulp-rename.

from gulp.

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.