Bing Lu
Bing Lu

Reputation: 3392

Angular2 with webpack production: "Failed to load app/app.component.html"

My project is based on Angular2-webpack-starter. It's currently with Angular2 rc.4 and webpack 1.13.1. If I run it in dev mode, everything works well.

dev mode result

But if running under production mode, I get Failed to load app/app.component.html exception due to GET http://localhost:8080/app/app.component.html 404 (Not Found).

enter image description here

I check the webpack.common.js, webpack.dev.js and webpack.prod.js files. There is nothing special for the prod configuration and the html loader is actually in the shared webpack.common.js file. I'm seeking help about how to debug this issue.

Upvotes: 2

Views: 2151

Answers (1)

mover333
mover333

Reputation: 683

The angular2-webpack-starter uses the angular2-template-loader to keep track of html and style dependencies and, as far as I understand it, ends up changing your templateUrl: properties in your component to template: properties and actually inlines the HTML file there. So your app shouldn't even be calling for the html file. Did you alter the common config file to remove the angular2-template-loader? Its on line 143 in the common config (https://github.com/AngularClass/angular2-webpack-starter/blob/master/config/webpack.common.js).

Also make sure your tsconfig.json is set up properly for the awesome loader, as angular2-template-loader needs the useWebpackText property set to true. See here (under Requirments): https://github.com/TheLarkInn/angular2-template-loader

Upvotes: 4

Related Questions