This repository was archived by the owner on Dec 4, 2017. It is now read-only.
This repository was archived by the owner on Dec 4, 2017. It is now read-only.
Misconfiguration in "Advanced - Webpack: an introduction" example #2585
Closed
Description
Issue
The following 404 may occur when running the example:
zone.js:1274 GET http://localhost:8080/app.component.html 404 (Not Found)
Reproducing the issue
- Create a project from the source files listed here: https://angular.io/docs/ts/latest/guide/webpack.html
- Run Typescript compiler manually:
tsc
- Run webpack-dev-server:
npm start
Cause
Within webpack.common.js, the following resolve configuration is used:
resolve: {
extensions: ['', '.js', '.ts']
}
This configuration causes webpack to utilize js files over ts files to satisfy imports. This in turn means that angular2-template-loader and html-loader never get the chance to replace templateUrl values.
loaders: [
// these loaders never touch component ts files if js equivalents exist in the same folder
{
test: /\.ts$/,
loaders: ['awesome-typescript-loader', 'angular2-template-loader']
},
{
test: /\.html$/,
loader: 'html'
}...
]
Solution
Webpack should prioritize ts files:
resolve: {
// ts before js
extensions: ['', '.ts', '.js']
}
Metadata
Metadata
Assignees
Labels
No labels