Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
refactor: allow aliases
  • Loading branch information
snitin315 committed Jul 27, 2022
commit 00fae2fca6baa314b46e6207fd9bc54b141cd5f9
5 changes: 5 additions & 0 deletions packages/webpack-cli/src/webpack-cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -472,6 +472,11 @@ class WebpackCLI implements IWebpackCLI {
makeOption(command: WebpackCLICommand, option: WebpackCLIBuiltInOption) {
let mainOption: WebpackCLIMainOption;
let negativeOption;
const flagsWithAlias = ["devtool", "output-path", "target", "watch"];

if (flagsWithAlias.includes(option.name)) {
option.alias = option.name[0];
}

if (option.configs) {
let needNegativeOption = false;
Expand Down
6 changes: 2 additions & 4 deletions test/build/core-flags/core-flags.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -239,17 +239,15 @@ describe("core flags", () => {
expect(stdout).toContain(`devtool: 'source-map'`);
});

// TODO: Enable alias with webpack 5
it.skip("should allow string value devtool option using alias", async () => {
it("should allow string value devtool option using alias", async () => {
const { exitCode, stderr, stdout } = await run(__dirname, ["-d", "source-map"]);

expect(exitCode).toBe(0);
expect(stderr).toBeFalsy();
expect(stdout).toContain(`devtool: 'source-map'`);
});

// TODO: Enable alias with webpack 5
it.skip("should allow string value devtool option using alias #1", async () => {
it("should allow string value devtool option using alias #1", async () => {
// cSpell:ignore dsource
const { exitCode, stderr, stdout } = await run(__dirname, ["-dsource-map"]);

Expand Down
3 changes: 1 addition & 2 deletions test/build/target/flag-test/target-flag.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ describe("--target flag", () => {
expect(stdout).toContain(`target: [ '${val}' ]`);
});

// TODO: Enable aliases with webpack 5
it.skip(`should accept ${val} with -t alias`, async () => {
it(`should accept ${val} with -t alias`, async () => {
const { exitCode, stderr, stdout } = await run(__dirname, ["-t", `${val}`]);

expect(exitCode).toBe(0);
Expand Down
Loading