diff --git a/README.md b/README.md index b5bb120..4b76e3e 100644 --- a/README.md +++ b/README.md @@ -63,18 +63,18 @@ Or it can be added to `package.json`: #### download-federated-types | Option | Default value | Description | |-------------------------------|-------------------|---------------------------| -| `--webpack-config` | `webpack/prod.ts` | Path to webpack-config.js | +| `--webpack-config` | `webpack/prod.ts` | Path to webpack.config.js | If the config is written in TypeScript, the script should be called with `npx ts-node`. #### make-federated-types -| Option | Default value | Description | -|-------------------------------|-------------------|--------------------------------------------------------------------------------| -| `--output-types-folder`, `-o` | `dist/@types` | Path to the output folder, absolute or relative to the working directory | -| `--global-types`, `-g` | `src/@types` | Path to project's global ambient type definitions, relative to the working dir | -| `--federation-config`, `-c` | `src/@types` | Path to federation.config, relative to the working dir | -| `--tsconfig`, `-t` | `src/@types` | Path to tsconfig.json, relative to the working dir | -| `--webpack-config` | `webpack/prod.ts` | Path to webpack-config.js | +| Option | Default value | Description | +|-------------------------------|---------------------|--------------------------------------------------------------------------------| +| `--output-types-folder`, `-o` | `dist/@types` | Path to the output folder, absolute or relative to the working directory | +| `--global-types`, `-g` | `src/@types` | Path to project's global ambient type definitions, relative to the working dir | +| `--federation-config`, `-c` | `src/@types` | Path to federation.config, relative to the working dir | +| `--tsconfig`, `-t` | `src/@types` | Path to tsconfig.json, relative to the working dir | +| `--webpack-config` | `webpack.config.js` | Path to webpack.config.js | ## Plugin Configuration diff --git a/src/bin/download-federated-types.ts b/src/bin/download-federated-types.ts index 063aadd..f5e2ae6 100644 --- a/src/bin/download-federated-types.ts +++ b/src/bin/download-federated-types.ts @@ -23,7 +23,7 @@ type Argv = { }; const argv = parseArgs(process.argv.slice(2)); -const webpackConfigPath = argv['webpack-config'] || 'webpack/prod.ts'; +const webpackConfigPath = argv['webpack-config'] || 'webpack.config.js'; const { mfPluginOptions, mfTypesPluginOptions } = getOptionsFromWebpackConfig(webpackConfigPath); diff --git a/src/bin/helpers/getOptionsFromWebpackConfig.ts b/src/bin/helpers/getOptionsFromWebpackConfig.ts index b002233..ec5c2cd 100644 --- a/src/bin/helpers/getOptionsFromWebpackConfig.ts +++ b/src/bin/helpers/getOptionsFromWebpackConfig.ts @@ -1,3 +1,5 @@ +import path from 'path'; + import { Compiler } from 'webpack'; import { ModuleFederationTypesPluginOptions } from '../../models'; @@ -5,7 +7,7 @@ import { ModuleFederationTypesPluginOptions } from '../../models'; export function getOptionsFromWebpackConfig(webpackConfigPath: string) { let webpackConfig: Compiler['options']; try { - webpackConfig = require(webpackConfigPath); + webpackConfig = require(path.join(process.cwd(), webpackConfigPath)); webpackConfig = ((webpackConfig as unknown as Dict).default as Compiler['options']) || webpackConfig; } catch (error) { console.error(`Failed to import webpack config from ${webpackConfigPath}:`, error);