TrilonIO / aspnetcore-angular-universal

ASP.NET Core & Angular Universal advanced starter - PWA w/ server-side rendering for SEO, Bootstrap, i18n internationalization, TypeScript, unit testing, WebAPI REST setup, SignalR, Swagger docs, and more! By @TrilonIO
https://www.trilon.io
MIT License
1.46k stars 434 forks source link

How to set image paths correctly #725

Open vslzl opened 5 years ago

vslzl commented 5 years ago

I'm trying to set image src paths and css background image paths as follows:

<img src="images/1.png" />

or

.some-css-class{
    background-color:url('images/1.png');
}

but I'm getting error

NodeInvocationException: Prerendering failed because of error: Error: Cannot find module './images/1.png' at webpackMissingModule (webpack-internal:///./ClientApp/app/layout/layout.component.html:1:1035) at eval (webpack-internal:///./ClientApp/app/layout/layout.component.html:1:1124) at Object../ClientApp/app/layout/layout.component.html

my image file is at wwwroot/images/1.png

AsifulNobel commented 5 years ago

Adding a slash before images will do the trick. So, the path should be as follows: <img src="/images/1.png" />