Skip to content
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
@JeremyTCD

Description

@JeremyTCD

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

  1. Create a project from the source files listed here: https://angular.io/docs/ts/latest/guide/webpack.html
  2. Run Typescript compiler manually: tsc
  3. 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

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions