Skip to content

Commit

Permalink
build: no longer fallback to index.html file (#5879)
Browse files Browse the repository at this point in the history
  • Loading branch information
devversion authored and kara committed Jul 20, 2017
1 parent 844c5be commit 93b36b3
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions tools/gulp/util/task_helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,12 +148,17 @@ export function serverTask(packagePath: string, livereload = true) {
root: projectDir,
livereload: livereload,
port: 4200,
fallback: path.join(packagePath, 'index.html'),
middleware: () => {
return [httpRewrite.getMiddleware([
// Rewrite the node_modules/ and dist/ folder to the real paths. This is a trick to
// avoid that those folders will be rewritten to the specified package path.
{ from: '^/node_modules/(.*)$', to: '/node_modules/$1' },
{ from: '^/dist/(.*)$', to: '/dist/$1' },
{ from: '^(.*)$', to: `/${relativePath}/$1` }
// Rewrite every path that doesn't point to a specific file to the index.html file.
// This is necessary for Angular's routing using the HTML5 History API.
{ from: '^/[^.]+$', to: `/${relativePath}/index.html`},
// Rewrite any path that didn't match a pattern before to the specified package path.
{ from: '^(.*)$', to: `/${relativePath}/$1` },
])];
}
});
Expand Down

0 comments on commit 93b36b3

Please sign in to comment.