Reputation: 121
Whenever I change basehref to "/v2/" (or any other value other than "/") via ng build --prod --base-href /v2/
I get the following error:
Angular 7 SyntaxError: expected expression, got '<'
Upvotes: 2
Views: 935
Reputation: 7115
this is an overkill:
ng build --aot --prod
because prod always performs aot so that parameter is not needed, please use:
ng build --prod --base-href
Source: https://angular.io/guide/deployment
Also < base href="/v2"> instead of < base href="/v2/">
Then to make sure the assets are not lost I added a folder src/app/v2/assets/images and updated the css to reference the new path and the angular.json
"assets": ["src/favicon.ico","src/v2/assets"]
Upvotes: 1
Reputation: 71
I have too noticed this behaviour migrating from v6 -> v7. If you are using routing try using your wildcard route (**) as this
{
path: '', component: DashboardComponent, children: [
{ path: 'comp1', component: FirstComponent },
{ path: 'comp2', component: SecondComponent },
{ path: 'comp3', component: ThirdComponent },
{ path: '**', redirectTo: '/comp1', pathMatch: 'full'}
]
}
In v6 this was working as well, but not in v7
{ path: '**', redirectTo: 'comp1', pathMatch: 'full'}
Long story short, if you add this at the end of your routing paths, it should work
{ path: '**', redirectTo: '/', pathMatch: 'full'}
Upvotes: 0