Tom
Tom

Reputation: 17864

How to import simple bit-src component into projects' /src folder?

I'm trying bit-src (or should I call it bit.dev?) for the first time...

I have two files - a .ts with just 1 dependency and a .md with its docs - which I use in many projects, which I want to turn into a bit component.

So, I find these two files in the /src folder of one of my projects, add it as a component, tag it and then export it to my collection. So far so good.

Then I go to another project that needs to share in the use of this component and I try to import it (if the files were already there I deleted them first)..

$ bit import <user>.<colx>/<component> --path src

I get an error message stating that the directory is not empty (which is true).

If I do install it into its own directory then it also creates a bunch of overhead I don't want, but I guess that's not the point - it should be in my /src folder along with other code, same as it was in the project I created it from.

Is there some way to do what I want? Or should I be using a different tool entirely?

Upvotes: 0

Views: 809

Answers (2)

Uri Kutner
Uri Kutner

Reputation: 161

It seems that using the --path <foldPath> flag places the component files directly at foldPath. this would include the /dist folder, node_modules, package.json, etc.

So, it makes sense to do this in a new, empty folder.

maybe use import like this? bit import ... --path ./src/componentName

Upvotes: 0

Josh
Josh

Reputation: 668

if you want to change the default location of imported component, you can do it by edit the bit configuration in the package.json, from this:

"bit": {
    "env": {},
    "componentsDefaultDirectory": "components/{name}",
    "packageManager": "npm"
  }

to this:

"bit": {
    "env": {},
    "componentsDefaultDirectory": "src/{name}",
    "packageManager": "npm"
  }

If you want to use the --path flag, you need to specify the folder, like this:
bit import <user>.<colx>/<component> --path src/<component>

I hope it will help you 😃

Upvotes: 2

Related Questions