Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[webpack-cli 4.0.0] Unknown argument: --env.source=src/examples/* #1942

Closed
doberkofler opened this issue Oct 13, 2020 · 6 comments
Closed

[webpack-cli 4.0.0] Unknown argument: --env.source=src/examples/* #1942

doberkofler opened this issue Oct 13, 2020 · 6 comments

Comments

@doberkofler
Copy link

Bug report

After migrating to webpack cli 4.0.0 i get the following error:

~/MyDev/ljs_app/trunk/periscope $ npx webpack --progress --env.source="src/examples/*"
[webpack-cli] Unknown argument: --env.source=src/examples/*
? Which flags do you want to use? …
✔ --entry: The entry point(s) of your application e.g. ./src/main.js
✔ --config: Provide path to a webpack configuration file e.g. ./webpack.config.js
✖ Which flags do you want to use? · No items were selected
[webpack-cli] Action Interrupted, use webpack-cli help to see possible options.

What is the current behavior?

If the current behavior is a bug, please provide the steps to reproduce.

npx webpack --progress --env.source="src/examples/*"

What is the expected behavior?

Other relevant information:
webpack version: 5.0.0
Node.js version: 14.13.0
Operating System: macOS 10.15.7
Additional tools:

@sokra sokra transferred this issue from webpack/webpack Oct 14, 2020
@anshumanv
Copy link
Member

This format is no longer supported in v4, we're working to enhance it here - #1939

Duplicate of #1932

@nevcos
Copy link

nevcos commented May 26, 2021

@anshumanv This breaking change is not referred on https://webpack.js.org/migrate/5/ or CHANGELOG, it's worth adding it.

This change is highly inconvenient because it affects CI scripts, which in our case need to work both with webpack 4 and 5:

# webpack-cli 3:
webpack --env.myFlag=true 
# runs ok, value available on script as `options.myFlag`

# webpack-cli 4:
webpack --env.myFlag=true
[webpack-cli] Error: Unknown option '--env.myFlag=true'

Is there any syntax that works on both webpack-cli v3 and v4?

Thanks!

@alexander-akait
Copy link
Member

@nevcos --env platform=staging --env production --env foo.bar=baz

@nevcos
Copy link

nevcos commented May 26, 2021

@alexander-akait It doesn't work the same way:

# webpack-cli 3:
webpack --env.myFlag=true # options is an object: {"myFlag":"true"}
webpack --env myFlag=true # options is a string: "myFlag=true"

# webpack-cli 4:
webpack --env myFlag=true # options is an object: {"WEBPACK_BUNDLE":true,"WEBPACK_BUILD":true,"myFlag":"true"}

@alexander-akait
Copy link
Member

If you need boolean value, you need just use --env myFlag (without any values)

@nevcos
Copy link

nevcos commented May 26, 2021

@alexander-akait It was just an example, in my case I need to send a string URL for source maps location.
I'll fix the CI script with an ugly if [[ ${WEBPACK_VERSION} == 4* ]], hopefully I'll be able to remove it soon 😅.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants