Often times I like to try out new things in web development and nodejs world. But there is one problem with it.
I have tried out to create a new projects using create-react-app, create-next-app or any backend app using express or hapi, or any monorepo using lerna, turbo or nx.
But the command to start development environment or build the project changes from one to another.
viz.
create-react-app
starts development environment with npm start
create-next-app
starts development environment with npm run dev
and so on.
and there is no one command to rule them all.
But don't worry there is one solution to it.
You need to have zsh, oh-my-zsh installed on your system to take advantage of the solution
Here is how you can do it
Step 1: Enable dotenv
plugin in zsh
. Edit your ~/.zshrc
plugins=(dotenv)
Now this plugin will always automatically source your .env
file everytime you cd into your project directory that contains a .env
file
Step 2: Create and add following content a .env
to create-react-app
project
alias ns="npm start"
alias nb="npm run build"
Step 3: Create and add following content a .env
to create-next-app
project
alias ns="npm run dev"
alias nb="npm run build"
Step 4: For java spring boot project you can add following
alias ns="mvn org.springframework.boot:spring-boot-maven-plugin:run"
Now when you cd
into create-react-app
project then all you need to run ns
to start project
also when you cd
into create-next-app
project then as well you need to run ns
to start the project
Thats it its just one time configuration you have to do in your project and you are done. No more remembering project specific commands. Cheers. Enjoy.
Top comments (1)
🥷 🧙♀️ wiki.zshell.dev 🧙♀️ 🥷