Skip to content

Instantly share code, notes, and snippets.

@thatisuday
Created September 12, 2020 22:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save thatisuday/9f5a3f16c0bd0248f845a4605bfa8726 to your computer and use it in GitHub Desktop.
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.
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