How to change the path before injection

236 views Asked by At

Is it possible to change the path of the injected file before injection occurs?

I am using Grunt/Bower/Connect/Wiredep, and my directory structure is:

www
|- dev-dist/
|- node_modules/
|- src/
|- vendor/
|- bower.json
|- Gruntfile.js
|- package.json

(Note: in my .bowerrc file I've added directory: vendor)

When I run the custom task grunt serve:dev it will create the directory dev-dist, I will then copy my index.html (only) to the folder, after which I run the task wiredep.

After running wiredep, the src paths to my dependencies are all prefixed with '../vendor/'. The problem is that when I run connect I have the option base: ['vendor', 'dev-dist', 'src']. When everything is served, the relative path to vendor doesn't make any sense because the vendor dir is already served at the root.

Is there a way I can modify the path to the injected files before wiredep injects them? (So I can remove the '../vendor')

What I would like to have happen is from the same workspace be able to run grunt serve:* and specify dev/stage/prod environments. This is why I did not want to serve the whole www directory.

Is there a way to exclude folders from being served in connect? (So instead of specifying base:[...], I can just exclude the stage-dist / prod-dist folders)

Thanks,

JD

1

There are 1 answers

0
Swaminathan Vetri On

You can use the option ignorePath with a regular expression

ignorePath: /\.\.\//,

from the wiredep to remove the ../ from the path that is getting injected. The configuration details are available over here https://github.com/taptapship/wiredep#configuration

I haven't used connect yet, so I am not sure of your second part of the question.