Skip to content
This repository has been archived by the owner on Apr 20, 2018. It is now read-only.

Ability to replace revved urls inside of js files #5

Closed
ghost opened this issue Dec 14, 2012 · 15 comments
Closed

Ability to replace revved urls inside of js files #5

ghost opened this issue Dec 14, 2012 · 15 comments
Assignees

Comments

@ghost
Copy link

ghost commented Dec 14, 2012

I would like to rev my templates that I use with angular, and they get referenced in my module declaration in angular, with a path of something like this:

$routeProvider.when('/dashboard', { templateUrl: 'templates/dashboard.html', controller: etv.DashboardCtrl });

I'm revving them up, but need to have them replaced in that one file. Is there any way to register an additional 'matcher' to have these replaced, or do I just need to fork the task to add that?

@ghost
Copy link
Author

ghost commented Dec 14, 2012

I made an angular processor here, if you're interested in a pull request, let me know and I'll put it together.

Angular Processor: https://gist.github.com/4289095

@ghost ghost assigned sleeper Dec 19, 2012
@sleeper
Copy link
Contributor

sleeper commented Dec 19, 2012

I like the idea of being able to register an additional matcher ... Going to have a look at this, as soon as yeoman is stabilised.

@sindresorhus
Copy link
Member

I know @btford did some similar replacing stuff in the Angular generator. What do you think?

@ghost
Copy link
Author

ghost commented Feb 21, 2013

Any idea where that work lives? What about adding in an option to usemin so that if you pass an object instead of a string, you can specify a pattern to match, so something like:

js: { pattern: /templateUrl:.?['"]([^"']+)["']/gm, path: '<%= yeoman.app %>/js/*.js' }

@btford
Copy link

btford commented Feb 21, 2013

I've made https://github.com/btford/grunt-google-cdn and https://github.com/btford/ngmin, but neither of those really are designed to address this issue. I'd say adding this to usemin, or making this into a new Grunt task would be the way to go.

@sindresorhus
Copy link
Member

A workaround for the time being regarding images is to, instead of having the path hardcoded in JS, put it in your HTML and the fetch it with JS. That way it will be correctly rev it. With images it would probably be better to place it in the CSS anyway.

@kav
Copy link

kav commented Aug 1, 2013

That's a bit of a mess of a workaround and while CSS is quite often the right place there are times when it isn't. Also running into places where an angular property (that isn't a standard tag) references an image and has the same problem. I'd be happy to add a custom matcher our enable some greedy match mode but as it stands it's a bit of a pain to work with. Any other suggestions?

@sleeper
Copy link
Contributor

sleeper commented Aug 2, 2013

V2.0 supports user defined matchers.

@dmitrybelyakov
Copy link

Hi guys, same problem here. Any updates on when 2.0 will be available from npm?

@robwierzbowski
Copy link

+1 to Usemin-ing references in the JS. It's often more proper to use a content image than a CSS background.

@justinmc
Copy link

I also would really like to see this feature. What am I supposed to do if I'm working in canvas or SVG and want to load an image? I figured a lot of people would have that problem, am I missing something? Fetching filenames from HTML or CSS seems super hacky in that case...

@frapontillo
Copy link

I'd like this feature as well.

@xdhmoore
Copy link

xdhmoore commented Dec 5, 2013

+1 for this feature. I am having this issue working on a project where we are dynamically building an SVG chart and setting the image paths in the JS.

@akatov
Copy link

akatov commented Mar 24, 2014

+1 please

@sindresorhus
Copy link
Member

This is too fragile to have in core, but define your own blocks: #337

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants