Skip to content

Commit 52adae2

Browse files
committed
Webpack auto gen resolve alias
- Updated Webpack config to use `tsconfig-paths-webpack-plugin` for resolve alias generation based on paths sest in `tsconfig.json`.
1 parent 665f170 commit 52adae2

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

webpack.config.js

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
const lodash = require('lodash');
22
const CopyPlugin = require('copy-webpack-plugin');
33
const HtmlWebpackPlugin = require('html-webpack-plugin');
4+
const TsconfigPathsPlugin = require('tsconfig-paths-webpack-plugin');
45
const path = require('path');
56

67
function srcPaths(src) {
@@ -17,15 +18,11 @@ const commonConfig = {
1718
output: { path: srcPaths('dist') },
1819
node: { __dirname: false, __filename: false },
1920
resolve: {
20-
alias: {
21-
_: srcPaths('src'),
22-
_main: srcPaths('src/main'),
23-
_models: srcPaths('src/models'),
24-
_public: srcPaths('public'),
25-
_renderer: srcPaths('src/renderer'),
26-
_utils: srcPaths('src/utils'),
27-
},
2821
extensions: ['.js', '.json', '.ts', '.tsx'],
22+
plugins: [new TsconfigPathsPlugin({
23+
configFile: './tsconfig.json',
24+
extensions: ['.js', '.json', '.ts', '.tsx'],
25+
})],
2926
},
3027
module: {
3128
rules: [

0 commit comments

Comments
 (0)