Configure Webpack for TypeScript
This commit is contained in:
parent
29974643b6
commit
074b34deca
2 changed files with 40 additions and 5 deletions
31
tsconfig.json
Normal file
31
tsconfig.json
Normal file
|
@ -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']
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
Reference in a new issue