Closed cherrydev closed 7 years ago
Excellent, that sounds very useful. On 19 Nov 2014 02:21, "cherrydev" notifications@github.com wrote:
Because the Vpp doesn't implement GetDirectory or DirectoryExists, the Bundle.IncludeDirectory method doesn't work at all, which unfortunately makes it rather limiting. I'm going to try to implement it, if that's alright with you.
— Reply to this email directly or view it on GitHub https://github.com/mcintyre321/EmbeddedResourceVirtualPathProvider/issues/11 .
Yes, would also need this feature. Without, I cannot use "*"-Includes when using System.Web.Optimization bundles.
I will implement this in following days.
I've made a pull request #32 that should fulfill this issue. But it comes with one big caveat, it only works for files that have exactly one period (filename.ext)
Awesome work @thorgeir . I'll need a bit of time to review this.
WRT the caveat - would it be possible to change is so files which contain multiple periods can be found at multuiple paths? e.g.
\foo\bar.baz.js
, which would become a resource foo.bar.baz.js
would be available at all combinations of virtual paths from /foo.bar.baz.js
, /foo/bar.baz.js
, /foo.bar/baz.js
, /foo/bar/baz.js
, if you see what I mean?
I haven't really though this through yet, so there may be a very good reason why this won't work.
If not though, it might be better if you could make this change, as it will stop people who aren't aware of the caveat from raising issues.
We could generate every possible combination. but the main usage for this would be with bundles and if you know about this limitation you should be able to adjust your filenames to fit the pattern. Right? :)
Also, if we make files accessible through all combinations, including ~/foo/*.js
in a bundle would include all .js files in all sub-directories.
So a big problem is it's pretty common for something to be called \js\jquery-1.5.1.min.js
, - could some client of (configurable?) heuristic be used, that works with version numbers and .min
?
Also, would my suggestion result in multiple identical files being returned? I'm not that familiar with the ins and outs of bundling.
Some thing like this?
^(?<assembly>Assembly.Name)(\.(?<directory>.*?))?\.(?<filename>[^.]*([\.-](?<version>[0-9]\.[0-9]\.[0-9])(\.min)?)?\.[^.]*)$
Fiddle
Very nice! Do you need the assembly name bit?
Also, might be worth treating .less.css
, .ts.js
specially too... although that can be done later, .min
is by far the most common case
The initial resource name includes the assembly name, but it could be remove that before running the regex. Also we could also make this configurable like the CacheControl bit.
Ok, i've pushed these changes to the pull request. Review this and let me know what you think.
Because the Vpp doesn't implement GetDirectory or DirectoryExists, the Bundle.IncludeDirectory method doesn't work at all, which unfortunately makes it rather limiting. I'm going to try to implement it, if that's alright with you.