Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
fix: improve check for custom webpack and webpack-dev-server package …
…existance
  • Loading branch information
snitin315 committed Jun 4, 2023
1 parent fa0553c commit 0931ab6
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions packages/webpack-cli/src/webpack-cli.ts
Expand Up @@ -57,8 +57,14 @@ const { pathToFileURL } = require("url");
const util = require("util");
const { program, Option } = require("commander");

const WEBPACK_PACKAGE = process.env.WEBPACK_PACKAGE || "webpack";
const WEBPACK_DEV_SERVER_PACKAGE = process.env.WEBPACK_DEV_SERVER_PACKAGE || "webpack-dev-server";
const WEBPACK_PACKAGE_IS_CUSTOM = !!process.env.WEBPACK_PACKAGE;
const WEBPACK_PACKAGE = WEBPACK_PACKAGE_IS_CUSTOM
? (process.env.WEBPACK_PACKAGE as string)
: "webpack";
const WEBPACK_DEV_SERVER_PACKAGE_IS_CUSTOM = !!process.env.WEBPACK_DEV_SERVER_PACKAGE;
const WEBPACK_DEV_SERVER_PACKAGE = WEBPACK_DEV_SERVER_PACKAGE_IS_CUSTOM
? (process.env.WEBPACK_DEV_SERVER_PACKAGE as string)
: "webpack-dev-server";

interface Information {
Binaries?: string[];
Expand Down Expand Up @@ -566,12 +572,12 @@ class WebpackCLI implements IWebpackCLI {
let skipInstallation = false;

// Allow to use `./path/to/webpack.js` outside `node_modules`
if (dependency === WEBPACK_PACKAGE && fs.existsSync(WEBPACK_PACKAGE)) {
if (dependency === WEBPACK_PACKAGE && WEBPACK_PACKAGE_IS_CUSTOM) {
skipInstallation = true;
}

// Allow to use `./path/to/webpack-dev-server.js` outside `node_modules`
if (dependency === WEBPACK_DEV_SERVER_PACKAGE && fs.existsSync(WEBPACK_PACKAGE)) {
if (dependency === WEBPACK_DEV_SERVER_PACKAGE && WEBPACK_DEV_SERVER_PACKAGE_IS_CUSTOM) {
skipInstallation = true;
}

Expand Down

0 comments on commit 0931ab6

Please sign in to comment.