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