From 26ac40cff41c98a2847b43df1e9a5fb6c93aad5b Mon Sep 17 00:00:00 2001 From: jashtanna007 Date: Thu, 9 Oct 2025 16:15:36 +0530 Subject: [PATCH 1/4] docs(guides): update getting-started to use ES6 syntax Fixes #7636 --- src/content/guides/getting-started.mdx | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/content/guides/getting-started.mdx b/src/content/guides/getting-started.mdx index 5f0d559f1a1d..fe7ffa2f903a 100644 --- a/src/content/guides/getting-started.mdx +++ b/src/content/guides/getting-started.mdx @@ -247,9 +247,12 @@ As of version 4, webpack doesn't require any configuration, but most projects wi **webpack.config.js** ```javascript -const path = require('path'); +import path from 'path'; +import { fileURLToPath } from 'url'; -module.exports = { +const __dirname = path.dirname(fileURLToPath(import.meta.url)); + +export default { entry: './src/index.js', output: { filename: 'main.js', From ffc75774ffc7ee2a18a0d864a9530adb44c1b5c6 Mon Sep 17 00:00:00 2001 From: jashtanna007 Date: Sun, 12 Oct 2025 13:54:35 +0530 Subject: [PATCH 2/4] Update src/content/guides/getting-started.mdx Co-authored-by: Even Stensberg --- src/content/guides/getting-started.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/content/guides/getting-started.mdx b/src/content/guides/getting-started.mdx index fe7ffa2f903a..6fdc124c5990 100644 --- a/src/content/guides/getting-started.mdx +++ b/src/content/guides/getting-started.mdx @@ -244,7 +244,7 @@ As of version 4, webpack doesn't require any configuration, but most projects wi |- index.js ``` -**webpack.config.js** +**webpack.config.mjs** ```javascript import path from 'path'; From 2a018b4bd449db2c3bc630d7cda2466628adfa98 Mon Sep 17 00:00:00 2001 From: jashtanna007 Date: Sun, 12 Oct 2025 14:42:29 +0530 Subject: [PATCH 3/4] docs(guides): add examples for mjs and cjs configs --- src/content/guides/getting-started.mdx | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/src/content/guides/getting-started.mdx b/src/content/guides/getting-started.mdx index 6fdc124c5990..e74f2aa60120 100644 --- a/src/content/guides/getting-started.mdx +++ b/src/content/guides/getting-started.mdx @@ -244,7 +244,9 @@ As of version 4, webpack doesn't require any configuration, but most projects wi |- index.js ``` -**webpack.config.mjs** + + + ```javascript import path from 'path'; @@ -259,7 +261,22 @@ export default { path: path.resolve(__dirname, 'dist'), }, }; -``` + + + +const path = require('path'); + +module.exports = { + entry: './src/index.js', + output: { + filename: 'main.js', + path: path.resolve(__dirname, 'dist'), + }, +}; + + + + Now, let's run the build again but instead using our new configuration file: From 5b9bdfe695b03615499fc183369b6e17c279f612 Mon Sep 17 00:00:00 2001 From: jashtanna007 Date: Thu, 30 Oct 2025 03:04:32 +0530 Subject: [PATCH 4/4] fix(docs): refine config file extension labels to cjs --- src/content/guides/getting-started.mdx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/content/guides/getting-started.mdx b/src/content/guides/getting-started.mdx index e74f2aa60120..9416b40e0c35 100644 --- a/src/content/guides/getting-started.mdx +++ b/src/content/guides/getting-started.mdx @@ -248,7 +248,7 @@ As of version 4, webpack doesn't require any configuration, but most projects wi -```javascript +````javascript import path from 'path'; import { fileURLToPath } from 'url'; @@ -263,7 +263,7 @@ export default { }; - + const path = require('path'); module.exports = { @@ -289,7 +289,7 @@ cacheable modules 530 KiB ./src/index.js 257 bytes [built] [code generated] ./node_modules/lodash/lodash.js 530 KiB [built] [code generated] 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.