webpack.config.js

suggest change
module.exports = {
    entry: './src/index',
    output: {
        path: __dirname + '/build',
        filename: 'bundle.js'
    },
    module: {
        rules: [{
            test: /\.tsx?$/,
            loader: 'ts-loader',
            exclude: /node_modules/
        }]
    },
    resolve: {
        extensions: ['.ts', '.tsx']
    }
};

The main components are (in addition to the standard entry, output and other webpack properties):

The loader

Create a rule that tests for the .ts and .tsx extensions, and specify ts-loader as the loader.

Resolve TS extensions

Also add the .ts and .tsx extensions to resolve.extensions, or webpack will not resolve an extensionless import such as ./src/index.

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents