emonney / QuickApp

ASP.NET Core / Angular startup project template with complete login, user and role management. Plus other useful services for Quick Application Development
https://www.ebenmonney.com/quickapp
MIT License
1.26k stars 594 forks source link

Problem displaying own static images #47

Closed moutono closed 6 years ago

moutono commented 6 years ago

Hi. I've used QuickApp as a base project and I started building my own application on top of it. I've added my own images to the "ClientApp\app\assets\images" folder. In my HomeComponent I've added this line: AddBuildingPng = require("../../assets/images/AddBuilding.png");

In the template I added this line: <img alt="AddBuildingPng" class="img-responsive" [src]="AddBuildingPng" />

When I inspect the generated code in chrome I can see that a base64 string was created but the image is not shown... only the alt text is shown. I expect that the base64 generated string is not correct.

When I create a new Quick App project from Visual Studio 2017 and add the same code above it works and the image is displayed.

As another test I copied the base64 string generated by the QuickApp and pasted it as the source of the in my own application. Now the image is displayed successfully.

So the base64 created by QuickApp seems to be correct. The base64 created by MyApp seems to be incorrect. So my question: is there a loader or a function somewhere that could affect the require keyword I've used and cause it to generate an incorrect base64 string when referencing an image?

Any ideas would be appreciated.

moutono commented 6 years ago

I manage to sort out this issue. In the webpack.config.js in the modules => rules element we hadd the following two lines:

{ test: /\.(png|jpg|jpeg|gif|svg)$/, use: 'url-loader?limit=25000' },
{ test: /\.(png|woff|woff2|eot|ttf|svg)$/, loader: 'url-loader?limit=100000' }

We just needed to remove the duplicate file extensions in the two lines ending up with this:

{ test: /\.(png|jpg|jpeg|gif|svg)$/, use: 'url-loader?limit=25000' },
{ test: /\.(woff|woff2|eot|ttf)$/, loader: 'url-loader?limit=100000' },

Now it works.