[Vuejs]-Can you import a library from one repo into a web app in another repo using Webpack?

0👍

I think the best way in your case is to move your common functionality to npm package and use it into dependencies of both webpack projects. This is the right way!

0👍

Finally found a solution to this. It’s all in webpack’s resolver. Things work in webpack v1, maybe because it has this line in the build/webpack.base.js

resolve: {
  fallback: [path.join(__dirname, '../node_modules')],
  ...

But webpack v2 doesn’t seem to work the same way. My work workaround looks like this…

resolve: {
  modules: [
    path.join(__dirname, '../node_modules/TheLibrary'),
    ...

Now it looks inside the symbolically linked library for its dependencies.

Note: If TheLibrary also has a symbolically linked library, then under this workaround you need to include that as well under the root web app. Something like this…

resolve: {
  modules: [
    path.join(__dirname, '../node_modules/TheLibrary'),
    path.join(__dirname, '../node_modules/TheLibrary/node_modules/Component'),
    ...

So still open to better solutions 🙂

Leave a comment