Skip to content
This repository has been archived by the owner on Sep 18, 2024. It is now read-only.

Support resolve.root #2

Open
paulfalgout opened this issue Apr 4, 2016 · 9 comments
Open

Support resolve.root #2

paulfalgout opened this issue Apr 4, 2016 · 9 comments

Comments

@paulfalgout
Copy link

Could this plugin be made to support resolve.root? Is there a way to consider it now?

The way I'm doing it now is grabbing my aliases off of my webpack config and prepending the root to them for the aliases I pass to this plugin.

@adriantoine
Copy link
Contributor

adriantoine commented Apr 28, 2016

Yeah I'll have a look at implementing resolve.root, it shouldn't be too hard.

@rochdev
Copy link

rochdev commented Jun 8, 2016

+1

@adriantoine
Copy link
Contributor

adriantoine commented Aug 8, 2016

The issue I have there is that I'm not sure how the resolve.root option works 🤔 The webpack documentation is unclear.

EDIT: What I really don't get is how doesn't work when you have both a root and aliases 🤔

@vpotravnyy
Copy link

We're using babel-plugin-webpack-alias for running our tests in Mocha without full build.
Today it stopped work for us after dependencies update
Upon running tests we've got such error: Error: Cannot find module 'actions/api' throwing from very first test

Here's resolve part of our config:

var path = require('path')

module.exports = {
   "resolve":{
      "root": path.resolve(__dirname),
      "modulesDirectories":[
         "node_modules",
         "actions",
         "components",
         ...
      ],
      "alias":{
         "commonActions":"actions",
         "apiActions":"actions/api",,
         "customFormActions":"actions/formCustom",
         "components":"components",
         "formComponents":"components/form",
         ...
      },
      "extensions": ['', '.json', '.js', '.jsx']
   },
   ...
}

P.S. We finished up in approach from first comment: create separate test config with absolute paths for aliases. That works for us but may confuse other users of this library

@adriantoine
Copy link
Contributor

@vpotravnyy Hi! Sorry for the issue, I will look at it

@adriantoine
Copy link
Contributor

At the moment it doesn't work with extensions and relative aliases... I'm working on a fix right now

@adriantoine
Copy link
Contributor

@vpotravnyy I'm moving that to another bug as it is not related to the resolve.root support: #14 Thanks for raising the issue!

@jharris4
Copy link

I've been playing around doing something similar to what this plugin seems to do, and I found that the resolveLoader.root was what I had to use instead of resolve.root see this issue for more info: webpack/webpack#207

@jharris4
Copy link

In case anyone's interested, I just published the utility I've been using to get webpack to play nice with aliases here: https://www.npmjs.com/package/webpack-local-libs

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

No branches or pull requests

5 participants