jaesung2061 / anvel

Angular 2 Laravel Starter Kit
94 stars 25 forks source link

how i deploy this app on live server #34

Open vishal-bluesys opened 6 years ago

vishal-bluesys commented 6 years ago

app not working on live server where showing error js file not found

HexagonStorms commented 6 years ago

I'm also running into this issue. Anyone have any suggestions?

HexagonStorms commented 6 years ago

I figured it out: When deploying to a live server, you need to do either 2 things:

Option 1: Running ng build in the deploy script Depending on what live server you use, if you run into a 'FileNotFound' laravel error, that means that ng build did not run on the live server. And the default .gitignore hides the /dist/index compiled angular files (those are the files created when running ng build). So just make sure your live server is running ng build, and it'll create the necessary dist folder.

Option 2: Removing public/dist from the gitignore file. If you are like me and deployed to Heroku, it will detect the codebase as a PHP laravel app and correctly run composer install, but it will not run ng build. If you just remove public/dist from the gitignore file, then commit that, then run your git deploy script (in my case, git push heroku master), then those files will be on the live server and you'll be good to go.

The downside of Option 2 is that your compiled file might contain sensitive information. Important API keys, etc may be inside of this file, I believe. Be cautious of what's available publicly should someone unauthorized gain access to your server.