stephenplusplus/grunt-wiredep

why do I always get "../myapp/" before "bower_component/..." path?

Closed this issue · 2 comments

Hi,

I'm always getting the link as

<script src="../myapp/bower_components/jquery/dist/jquery.js"></script>

As you can see it always put an unnecessary "../myapp" prefix to the path, causing the resource cannot be loaded through http.

Any idea how this could happen?

here is my grunt config:

wiredep: {
  app: {
    src: [
      'views/layouts/layout.ejs',
      'views/static_pages/index.ejs'
    ],
    ignorePath:  /\.\.\//,
    cwd: 'myapp'
  },

}

The project layout:

project/

  • myapp/
  • - bower_components/
  • - views/
  • - bower.json

Thanks in advance.

By default, the path that's injected is a relative mapping from your src file to the Bower package's file. So, with that hierarchy, it should be:

"../../bower_components/jquery/dist/jquery.js"

The ignorePath is replacing the first ../ it finds. If you want to end up with:

"bower_components/jquery/dist/jquery.js"

You can make your ignorePath /\.\.\//g or just the string ../../

@stephenplusplus I see, thanks for your quick response. Turned out the ignorePath should be set to "../../myapp". Thanks for reminding me to check ignorePath, the grunt file was generated and I totally missed this option.