-
Notifications
You must be signed in to change notification settings - Fork 90
Add external streams to assets #116
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 modifies the code created by #70, but I'm not sure is this code is supported or not. It isn't documented or tested, and the last comment before the merge was "please try this out" and comments after the merge seem to indicate it doesn't work. If that code was supposed to work, I'll move the additional asset streams to the options instead of arguments. |
I misunderstood the intention of #70, and I now see that it is unrelated to the passing of assets streams. I've updated the code accordingly. Usage is now: // create stream of virtual files
var tsStream = gulp.src("src/**/*.ts")
.pipe(ts());
// pass stream to assets, multiple streams are supported
var assets = useref.assets({ additionalStreams: tsStream });
// use gulp-useref normally
return gulp.src("src/index.html")
.pipe(assets)
.pipe(assets.restore())
.pipe(useref())
.pipe(gulp.dest("dist")); This pull request is not ready to be merged. File order is not preserved between physical and virtual files, and I have an issue with using gulp-inject in the same workflow that I'm still looking into. This is more a request for comments or suggestions. :) |
Ok, this takes care of the ordering and the race condition with gulp-inject. Example workflow is: var tsStream = gulp.src("src/**/*.ts")
.pipe(ts());
var assets = useref.assets({ additionalStreams: tsStream });
return gulp.src("src/index.html")
.pipe(inject(tsStream, {relative: true}))
.pipe(assets)
.pipe(assets.restore())
.pipe(useref())
.pipe(gulp.dest("dist")); I'll test it with my full workflow (wiredep, rev, etc) on monday when I'm back at the office, but for now it looks good. I'd like to know if you'd be willing to pull, and if so, I'll update the docs and create some automated tests. |
Yes, this is addressing both these issues. I'm using typescript here, but I could also be using sass, less, coffeescript, dart, angular-templatecache, etc. Currently if I want to use gulp-useref with typescript, I have to generate the files, save them to a temp directory, then use gulp-useref. This pull request lets me pass streams of generated files to useref instead, which is more "gulpy". In my last example I'm using gulp-inject to automatically add the script tags for the files generated by typescript to my index.html before running gulp-useref. Let me know if you have any questions. Thanks. |
Yes, looks good. Please continue this work. Thanks! |
Ok, I think I finally solved the race condition between the streams. Changes appear worst than they really are since I add to re-indent most of the assets function. Basically, the change since the last version is waiting for the additional assets to run the main assets function. Still trying to break it, will let you know when I'm done. |
Was this done or forgotten? |
Neither. The code looks good to go, I was planning on creating some automated tests and updating the readme this weekend. |
All done. |
Can you squash your commits? |
Done. |
First draft of adding external streams to assets. Fixes #75 and #30. I updated an undocumented piece of code that appeared to do a similar job. If this is an acceptable solution, I'll create tests and update the doc.
Sample usage (with typescript):