'How to update the dist folder of Vue js without running npm run build a second time
I ran npm run build to create a dist folder for my Vue js application, which I then pushed to git hub. But after making changes in my codebase, I still ran npm run build which then automatically create a new dist folder and replaced the former. So how can I prevent running the build command many times and just update the dist folder directly.
Solution 1:[1]
Initialize the dist folder for a git repository where u host yr deployment for the final build. Then push the dist contents to the remote repo and then next time u make a deployment then since the dist folder is initialized for git when u push the dist contents it then updates the remote repo contents
assuming you are in project folder e.g my project
cd dist
git init
git remote add origin <remote repo URL>
git push -u origin <branch-name>
Then do what you do (making changes to the project and run again npm run build
Then push again, changes in the remote repo will be available and u can pull the new contents and deploy. Hope this helps.
Solution 2:[2]
You can run vite build --watch that will be updating constantly while updating your vue files. In package.json I've added a script "updater":"vite build --watch" in scripts
and to deploy it to github constantly (as git commit doesn't work with me) so I created push.js in the ./ (root) dir and used var ghpages = require('gh-pages');ghpages.publish('dist', function(err) {}); in push.js
and I hope this helps you and works with you too
and again in package.json I've added a script
"push" : "node push.js"
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Jose Mhlanga |
| Solution 2 |
