Schlagwort-Archive: HTML5

Publish Angular2-App using Webpack

$ npm run build:prod

This creates a folder called dist. This folder has to be copied to the webserver. I ran into the issue that an error appeared on reloading a page.

I’m not using the hash for routing ({useHash: false}), so all links appear as real paths like
But so reloading a sub-page leads to a 404-server-error „Page not found“ because the current path could not be located server-side.
Solution is to add some lines to .htaccess:

RewriteEngine On
# If an existing asset or directory is requested go to it as it is
RewriteRule ^ - [L]
# If the requested resource doesn't exist, use index.html
RewriteRule ^ /index.html

Thanx to Dan Mindru.