Created
September 12, 2020 22:05
-
-
Save thatisuday/9f5a3f16c0bd0248f845a4605bfa8726 to your computer and use it in GitHub Desktop.
A simple Webpack configuration to compile TypeScript projects with fork-ts-checker-webpack-plugin.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const path = require( 'path' ); | |
const ForkTsCheckerWebpackPlugin = require( 'fork-ts-checker-webpack-plugin' ); | |
module.exports = { | |
// generate source maps | |
devtool: 'source-map', | |
// bundling mode | |
mode: 'production', | |
// entry files | |
entry: './src/index.ts', | |
// output bundles (location) | |
output: { | |
path: path.resolve( __dirname, 'dist' ), | |
filename: 'main.js', | |
}, | |
// file resolutions | |
resolve: { | |
extensions: [ '.ts', '.js' ], | |
}, | |
// loaders | |
module: { | |
rules: [ | |
{ | |
test: /\.tsx?/, | |
use: { | |
loader: 'ts-loader', | |
options: { | |
transpileOnly: true, | |
} | |
}, | |
exclude: /node_modules/, | |
} | |
] | |
}, | |
// plugins | |
plugins: [ | |
new ForkTsCheckerWebpackPlugin(), // run TSC on a separate thread | |
], | |
// set watch mode to `true` | |
watch: true | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment