Created
May 20, 2018 14:09
-
-
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
This file contains hidden or 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'), | |
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