Skip to content

Commit 12bf1b0

Browse files
fix: ensure TsconfigPathsPlugin is only added if tsconfig.json exists
1 parent cd49b15 commit 12bf1b0

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

config/webpack.common.config.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
const fs = require('fs');
12
const path = require('path');
23
const RemoveEmptyScriptsPlugin = require('webpack-remove-empty-scripts');
34
const TsconfigPathsPlugin = require('tsconfig-paths-webpack-plugin');
@@ -12,6 +13,8 @@ const {
1213
const paragonThemeCss = getParagonThemeCss(process.cwd());
1314
const brandThemeCss = getParagonThemeCss(process.cwd(), { isBrandOverride: true });
1415

16+
const tsconfigPath = path.resolve(__dirname, 'tsconfig.json');
17+
1518
module.exports = {
1619
entry: {
1720
app: path.resolve(process.cwd(), './src/index'),
@@ -46,9 +49,9 @@ module.exports = {
4649
'env.config': false,
4750
},
4851
extensions: ['.js', '.jsx', '.ts', '.tsx'],
49-
plugins: [
50-
new TsconfigPathsPlugin(),
51-
],
52+
plugins: fs.existsSync(tsconfigPath)
53+
? [new TsconfigPathsPlugin({ configFile: tsconfigPath })]
54+
: [], // Only add TsconfigPathsPlugin if tsconfig.json exists
5255
},
5356
optimization: {
5457
splitChunks: {

0 commit comments

Comments
 (0)