Skip to content

Instantly share code, notes, and snippets.

@saurabhpati
Created May 20, 2018 14:09
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 saurabhpati/5599dcb6e8f8c1752625d41ddca24055 to your computer and use it in GitHub Desktop.
Save saurabhpati/5599dcb6e8f8c1752625d41ddca24055 to your computer and use it in GitHub Desktop.
webpack.config.js file for setting up a react project with typescript and webpack
const path = require('path'),
webpack = require('webpack'),
HtmlWebpackPlugin = require('html-webpack-plugin');
module.exports = {
entry: {
app: ['./src/app/App.tsx', 'webpack-hot-middleware/client'],
vendor: ['react', 'react-dom']
},
output: {
path: path.resolve(__dirname, 'dist'),
filename: 'js/[name].bundle.js'
},
devtool: 'source-map',
resolve: {
extensions: ['.js', '.jsx', '.json', '.ts', '.tsx']
},
module: {
rules: [
{
test: /\.(ts|tsx)$/,
loader: 'ts-loader'
},
{ enforce: "pre", test: /\.js$/, loader: "source-map-loader" }
]
},
plugins: [
new HtmlWebpackPlugin({ template: path.resolve(__dirname, 'src', 'app', 'index.html') }),
new webpack.HotModuleReplacementPlugin()
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment