Skip to content

Instantly share code, notes, and snippets.

@asci
Last active June 30, 2019 10:10
Show Gist options
  • Save asci/9fe5ec7b7c0840ba042501027f21f080 to your computer and use it in GitHub Desktop.
Save asci/9fe5ec7b7c0840ba042501027f21f080 to your computer and use it in GitHub Desktop.
React TS kit 2019
yarn add @types/react @types/react-dom html-webpack-plugin ts-loader typescript webpack webpack-cli webpack-dev-server --dev
{
"compilerOptions": {
"allowJs": false,
"allowSyntheticDefaultImports": true,
"declaration": true,
"declarationDir": "./dist",
"forceConsistentCasingInFileNames": true,
"jsx": "react",
"lib": ["es6", "dom", "es2016", "es2017"],
"module": "esnext",
"moduleResolution": "node",
"noFallthroughCasesInSwitch": true,
"noImplicitAny": false,
"noImplicitReturns": true,
"noImplicitThis": true,
"noUnusedLocals": true,
"outDir": "./dist",
"skipLibCheck": true,
"sourceMap": true,
"strictNullChecks": true,
"suppressImplicitAnyIndexErrors": true,
"target": "es5"
},
"include": ["src"],
"exclude": ["node_modules", "dist"]
}
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
module.exports = {
mode: 'development',
devtool: 'inline-source-map',
devServer: {
contentBase: path.join(__dirname, 'dist'),
index: 'index.html',
port: 9000,
open: true,
},
entry: './src/index.tsx',
output: {
path: path.resolve(__dirname, 'dist'),
filename: 'bundle.js',
},
resolve: {
// Add '.ts' and '.tsx' as resolvable extensions.
extensions: ['.ts', '.tsx', '.js'],
},
plugins: [
new HtmlWebpackPlugin({
title: 'Development',
template: 'src/index.html',
}),
],
module: {
noParse: /__tests__|test/,
rules: [
{
test: /\.ts(x?)$/,
exclude: /node_modules/,
use: [
{
loader: 'ts-loader',
options: { onlyCompileBundledFiles: true },
},
],
},
],
},
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment