简体   繁体   中英

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM