Skip to content
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

Expose component's bower.json for rewriting #145

Open
MokoJumbie opened this issue Dec 17, 2014 · 6 comments
Open

Expose component's bower.json for rewriting #145

MokoJumbie opened this issue Dec 17, 2014 · 6 comments

Comments

@MokoJumbie
Copy link

It would be useful to have access to the values in each component's bower.json for use in the rewrite stage.

In my case, I would like to be able to do something in the config like:

fileTypes:
    html:
        replace:
            js: '<script type="text/javascript">window[{{bowerConfig.name}}] || document.write(\'<script src="js/vendor/{{filePath}}"><\/script>\');</script>'
@CWSpear
Copy link
Contributor

CWSpear commented Jan 8, 2015

Why are you doing it like this in the first place? It sounds like you have something set up in a way that shouldn't that is causes duplicate scripts to be included?

@MokoJumbie
Copy link
Author

In the case I mentioned I am trying to use a fallback to a local script in the event that a CDN fails. An example can be seen in h5bp (https://github.com/h5bp/html5-boilerplate/blob/master/src/index.html#L26).
I realize that this approach is not foolproof as there is no guarantee that the component will be exposed using the same value stored at bowerConfig.name, but I imagine it would be useful to expose a component's metadata for consumption by grunt/gulp tasks.

@CWSpear
Copy link
Contributor

CWSpear commented Jan 8, 2015

I believe the component name is the first part of filePath, i.e:

var componentName = filePath.split('/').shift();

@CWSpear
Copy link
Contributor

CWSpear commented Jan 8, 2015

i.e. that's bower's naming scheme: bower_components/{componentName}/{packageContents} (where bower_components is configurable in .bowerrc)

@stephenplusplus
Copy link
Member

Yeah, the name can be used here as @CWSpear suggested. I think it's a good idea to pass the whole bower config though - can't hurt! I'll mark this as "PR welcome" though, historically, that hasn't gotten much results :( Feel free to add this into the code if you have time!

@eddiemonge
Copy link
Contributor

still valid, if dubious value

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

No branches or pull requests

4 participants