Comments (17)
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.
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.
@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.
@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.
@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.
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.
@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.
Putting out a bounty of $5 to anyone who wants to make gulp-rename
from gulp.
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.
@hparra Exactly what I had in mind
from gulp.
@contra Me too. Will get to it later tonight.
from gulp.
from gulp.
@markgoodyear Released as gulp-rename.
@contra I guess you can close this!
from gulp.
@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.
Nice! @hparra DM me your gmail so I can send you a wallet payment
from gulp.
This really should be built-in functionality... It is extremely common to output files in the format name.min.ext
.
from gulp.
No, it should not, use gulp-rename.
from gulp.
Related Issues (20)
- gulp 5 seems to break existing streaming plugins HOT 16
- RangeError: Maximum call stack size exceeded HOT 2
- Gulp 5 corrupt images HOT 3
- v5 : Series tasks fail where running individually pass HOT 4
- Gulp 5 - Copied images using .src and .dest are corrupt HOT 3
- In gulp 4.0.2 fonts are displayed correctly, and in version 5.0.0 there are constant errors HOT 3
- Gulp v5.0.0 png and jpg images not opening after transferring via gulp HOT 2
- v5: after updating gulp to version 5, jpg and png files are not readable after src-dest processing HOT 7
- Option no-sort doesn't seem to work on gulp 5.0.0 HOT 5
- Gulp v5.0.0 does not work if the root folder contains too many files (Works in Gulp v4.0.2) HOT 1
- Static files broken HOT 2
- Simple gulp copy garbles font files HOT 10
- PNG files are corrupted after Gulp upgrade to 5.0 HOT 7
- v5: Stuck in infinite loop in some cases HOT 3
- Gulp.src/gulp.dest does not copy images or fonts correctly in [email protected] HOT 3
- Gulp v5 corrupt font files HOT 5
- not support node22 HOT 1
- gulp imagemin task is not working properly for the v5.0.0 gulp HOT 2
- Test fail on the latest version HOT 3
- `Unhandled 'error' event` error in gulp 5 HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gulp.