From 1f844f714323f49dd47699488e48704d3b9ef792 Mon Sep 17 00:00:00 2001 From: Greegko Date: Tue, 20 Jul 2021 09:24:47 +0200 Subject: [PATCH] resolve alias for core --- packages/core/tsconfig.json | 4 ++-- packages/web/config/webpack.config.js | 14 +++++++++++++- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/packages/core/tsconfig.json b/packages/core/tsconfig.json index c2513c5..f04624b 100644 --- a/packages/core/tsconfig.json +++ b/packages/core/tsconfig.json @@ -28,10 +28,10 @@ } }, "include": [ - "public-api.ts", + "public-api.ts" ], "exclude": [ "node_modules", "dist" - ], + ] } \ No newline at end of file diff --git a/packages/web/config/webpack.config.js b/packages/web/config/webpack.config.js index 0a48edf..1f78ddc 100644 --- a/packages/web/config/webpack.config.js +++ b/packages/web/config/webpack.config.js @@ -1,3 +1,9 @@ +const path = require('path'); +const rpgVillageCore = "../../core/"; +const tsconfig = require(path.resolve(__dirname, rpgVillageCore, 'tsconfig.json')); + +const rpgVillageDist = path.resolve(__dirname, rpgVillageCore, 'dist'); + module.exports = { entry: ["./src/main.tsx"], @@ -11,7 +17,13 @@ module.exports = { devtool: "source-map", resolve: { - extensions: [".webpack.js", ".web.js", ".js", ".ts", ".tsx"] + extensions: [".webpack.js", ".web.js", ".js", ".ts", ".tsx"], + alias: Object.keys(tsconfig.compilerOptions.paths).reduce((aliases, aliasName) => { + const aliasBase = aliasName.slice(0, -2); + const pathBase = tsconfig.compilerOptions.paths[aliasName][0].slice(0, -2); + + return { ...aliases, [aliasBase]: `${rpgVillageDist}/${pathBase}` }; + }, {}), }, module: {