Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork3.3k
docs: updated getting started guide to correct webpack config file extension to support CJS syntax#7518
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
base:main
Are you sure you want to change the base?
Uh oh!
There was an error while loading.Please reload this page.
Conversation
…ension to support CJS syntaxThe docs used import statement in index.js which requires setting `type: "module"`. There is a PR for the same `https://github.com/webpack/webpack.js.org/pull/7516`. This is to correct the webpack config file. The commonjs code won't work in *.js extension. So its changed to *.cjs.
@RajeevPullat is attempting to deploy a commit to theWebpack Docs Team onVercel. A member of the Team first needs toauthorize it. |
Abhijeet641 commentedJan 12, 2025
@RajeevPullat sir, did you fix the lint check ? could you please review my pr once#7513 |
@@ -237,14 +238,14 @@ As of version 4, webpack doesn't require any configuration, but most projects wi | |||
webpack-demo | |||
|- package.json | |||
|- package-lock.json | |||
+ |- webpack.config.js | |||
+ |- webpack.config.cjs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Can we provide two examples here - for CommonJS and ECMA modules format?
@@ -271,7 +272,7 @@ cacheable modules 530 KiB | |||
webpack 5.4.0 compiled successfully in 1934 ms | |||
``` | |||
T>If a`webpack.config.js`is present, the`webpack` command picks it up by default. We use the `--config` option here only to show that you can pass a configuration of any name. This will be useful for more complex configurations that need to be split into multiple files. | |||
T>By default, if you run the webpack command without specifying a configuration file, Webpack will look for certain default filenames. These typically include:`webpack.config.js`(for CommonJS format in JavaScript),`webpack.config.cjs` (for explicit CommonJS format) or `webpack.config.mjs` (for ES Modules). We use the `--config` option here only to show that you can pass a configuration of any name. This will be useful for more complex configurations that need to be split into multiple files. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
👍
Updated getting started guide to correct webpack config file extension to support CJS syntax
The docs used import statement in index.js which requires setting
type: "module"
. There is a PR raised for the samePR:7516. This PR to correct the webpack config file extension. The CommonJS code won't work in *.js extension and will throw below error.So its best changed to
webpack.config.cjs
.