-
Notifications
You must be signed in to change notification settings - Fork 90
Add Feature: allow pass stream to each asset files before concat #70
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
Conversation
This looks like a good way to solve #64
|
index.js
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be reasonable to set the base of the files to the base of file?
var stream = vfs.src(src, {base:file.base});
I need this to be able to get the right source values in the source-map.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hi, @sjurba, thanks for review this.
the glob pattern already contains path info. so we do not need extra options.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When using this to generate a sourcemap we need to set the base for the sources to have the correct relative paths. Without it, the sources list in the sourcemap will only contain the filename without any path info.
In other words, now the src glob has absolute urls:
/path/to/app/compA/file1.js
/path/to/app/compB/file2.js
Resulting in sourcemapping:
file1.js
file2.js
Where I want:
compA/file1.js
compB/file2.js
Setting the base property in the glob fixes that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sjurba updated. but The Travis CI build failed. it past on my own machine. I will check it later.
👍 |
e4b1ee6
to
8209011
Compare
Nice! |
👍 I'd find this useful as well. |
Why does this change break the tests? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
{base: file.base} option breaks the tests. if we remove the option, tests will pass. I do not have enough time to deal with it.
@chaizhenhua if that was a serious comment, then I find it extremely disrespectful. When you propose a change that breaks tests and your response is "I don't have time to deal with it", that will greatly decrease your chances of getting a pull request merged and is just bad behavior in general. Please refer to the guidelines on contributing here https://github.com/jonkemp/gulp-useref/blob/master/CONTRIBUTING.md and make note of the following.
If you don't have enough time for a pull request, then just make your comments in an existing issue or create a new one and leave it at that. Thanks. |
8209011
to
c853616
Compare
@jonkemp Don't be so serious. but your advice is useful. I said I will check it later and now i fix it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the nosort
option was added at some point before this and should be left in, unless there is a reason it was taken out.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if we set nosort to true the tests may fail sometimes.
I think it's beacuse the order of the sync output is undefined.
Ok, I finally had some time to review this. It seemed like there were significant code changes here, and indeed there are. This change doesn't just add support for sourcemaps. It changes how assets are read from the file system and concatenated. It's not even specific to sourcemaps. Assets can now be piped as a stream to any module that accepts streams. I think the biggest change here is the switch from using So I think this is good and worthy of being merged but I would like to get some more feedback on it before I include it. @sindresorhus @silvenon @addyosmani or anyone else who has time, if you would like to code review this change, it would be greatly appreciated. |
c853616
to
34d5141
Compare
Ok, if you check the latest code in this repo, I've added a 'noconcat' option that does not concat assets, but instead adds them to the stream. It's also been refactored significantly and supports streaming of assets to other plugins like gulp-sourcemaps. I would appreciate it if you would try this out before I release it to npm. Just check out the latest version and npm link it or copy it to your node_modules folder. Thanks! |
@jonkemp - I don't understand how this works. Look here... https://github.com/jonkemp/gulp-useref/blob/master/index.js#L110-L112 This won't work, I don't think. In fact, I think that what needs to happen is that all of the My point is, I cannot get sourcemaps to work with useref. Closest thing I have working is:
and I have modified useref as follows:
Hope that helps... |
I also haven't been able to get sourcemaps working. I'm using this for my task:
And the files its being run on is just a bunch of bower_components files:
Sourcemaps aren't being created at all. |
I don't get the sourcemaps to work. That's the error thrown:
|
I am getting exactly the same error as @Chalkin :
|
same exception |
same exception, if i used below line npm list gulp-useref |
hello @jonkemp, this patch allow transform assets before concat. now the syntax is like
$.useref.assets(opts, streamForEachAssetsBeforeConcat1, streamForEachAssetsBeforeConcat2, ...)
Now we can allow sourceMaps for assets concat in this way: