Configure Webpack for TypeScript

jh-changes
Shin'ya Ueoka 6 years ago
parent 29974643b6
commit 074b34deca
  1. 31
      tsconfig.json
  2. 14
      webpack.config.js

@ -0,0 +1,31 @@
{
"compilerOptions": {
"target": "es2017",
"module": "commonjs",
"allowJs": true,
"checkJs": true,
"jsx": "react",
"declaration": true,
"declarationMap": true,
"sourceMap": true,
"outDir": "./build",
"removeComments": true,
"importHelpers": true,
"strict": true,
"noImplicitAny": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"strictBindCallApply": true,
"strictPropertyInitialization": true,
"noImplicitThis": true,
"alwaysStrict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noImplicitReturns": true,
"moduleResolution": "node",
"esModuleInterop": true
}
}

@ -20,12 +20,16 @@ config = {
module: { module: {
rules: [ rules: [
{ {
test: [ /\.js$/, /\.jsx$/ ], test: [ /\.js$/, /\.jsx$/, /\.ts$/, /\.tsx$/],
exclude: /node_modules/, exclude: /node_modules/,
loader: 'babel-loader', loader: 'babel-loader',
query: { options: {
presets: ['@babel/react'] presets: [
} { plugins: ['@babel/plugin-proposal-class-properties'] },
'@babel/react',
'@babel/preset-typescript'
]
},
}, },
{ {
test: /\.css$/, test: /\.css$/,
@ -39,7 +43,7 @@ config = {
}, },
resolve: { resolve: {
extensions: [ '.js', '.jsx' ], extensions: [ '.js', '.jsx', '.ts', '.tsx' ],
modules: [path.join(__dirname, 'src'), 'node_modules'] modules: [path.join(__dirname, 'src'), 'node_modules']
}, },