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):
For this you need to create a rule that tests for the .ts
and .tsx
file extensions, specify ts-loader
as the loader.
You also need to add the .ts
and .tsx
extensions in the resolve
array, or webpack won't see them.