Phantom007
Phantom007

Reputation: 2249

How to share code between two or more projects

What is the best and easiest way to share code between a react and nodejs app (both are using vanilla JS)

Consider the following snippet

function slugify(str) {

  return str.replace(/[^a-z0-9)(\.\-_\s]/gi, "");
}

How do i use this piece of code with react and nodejs? This is just one function, but in my project there are several other codes that I need to use in both my react and nodejs app.

I know this can be done by creating npm module, but i think its a time consuming task.

Please suggest an alternate solution

Upvotes: 0

Views: 327

Answers (1)

ridoansaleh
ridoansaleh

Reputation: 624

If you are using Git in your projects. You could use Git Submodules.

Upvotes: 2

Related Questions