My project structure includes a crucial src/ts
folder:
- dist/
- js/
- css/
- index.html
- about.html
- src/
- assets/
- fonts/
- images/
- sass/
- ts/
- services/
- service1.ts
- service2.ts
- utils/
- util1.ts
- util2.ts
- index.ts
- about.ts
The issue at hand:
I am working with Webpack to generate declaration files. I need these files to be output in the directory dist/types
. However, my current webpack configuration places the declarations in dist/src/ts/
.
My configuration:
tsconfig.json
{
"compilerOptions": {
"outDir": "./dist/",
"sourceMap": true,
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noImplicitAny": true,
"removeComments": true,
"declaration": true, // Generates declaration files .d.ts
"strictNullChecks": true,
"module": "es6",
"target": "es5",
"jsx": "react",
"allowJs": true,
"moduleResolution": "node",
}
}
Utilizing ts-loader
in webpack config file.
module: {
rules: [
{
test: /\.tsx?$/,
use: 'ts-loader',
exclude: /node_modules/,
},
],
},