Skip to content

Instantly share code, notes, and snippets.

@awwsmm
Forked from thatisuday/webpack.config.js
Last active March 13, 2022 21:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save awwsmm/4262b75757573b1965ce8dad640b098f to your computer and use it in GitHub Desktop.
Save awwsmm/4262b75757573b1965ce8dad640b098f 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: './sandbox/index.ts',
// output bundles (location)
output: {
path: path.resolve( __dirname, 'build' ),
filename: 'index.js',
},
// file resolutions
resolve: {
extensions: [ '.ts', '.js' ],
alias: {
src: path.resolve(__dirname, 'src/')
},
},
// 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