@@ -35,6 +35,7 @@ contributors:
3535 - atesgoral
3636 - snitin315
3737 - artem-malko
38+ - Brennvo
3839related :
3940 - title : <link rel="prefetch/preload" /> in webpack
4041 url : https://medium.com/webpack/link-rel-prefetch-preload-in-webpack-51a52358f84c
@@ -83,9 +84,13 @@ console.log(_.join(["Another", "module", "loaded!"], " "));
8384** webpack.config.js**
8485
8586``` diff
86- const path = require('path');
87+ import path from 'node:path';
88+ import { fileURLToPath } from 'node:url';
8789
88- module.exports = {
90+ const __filename = fileURLToPath(import.meta.url);
91+ const __dirname = path.dirname(__filename);
92+
93+ export default {
8994- entry: './src/index.js',
9095+ mode: 'development',
9196+ entry: {
@@ -131,9 +136,13 @@ The [`dependOn` option](/configuration/entry-context/#dependencies) allows to sh
131136** webpack.config.js**
132137
133138``` diff
134- const path = require('path');
139+ import path from 'node:path';
140+ import { fileURLToPath } from 'node:url';
141+
142+ const __filename = fileURLToPath(import.meta.url);
143+ const __dirname = path.dirname(__filename);
135144
136- module.exports = {
145+ export default {
137146 mode: 'development',
138147 entry: {
139148- index: './src/index.js',
@@ -160,9 +169,13 @@ If we're going to use multiple entry points on a single HTML page, `optimization
160169** webpack.config.js**
161170
162171``` diff
163- const path = require('path');
172+ import path from 'node:path';
173+ import { fileURLToPath } from 'node:url';
174+
175+ const __filename = fileURLToPath(import.meta.url);
176+ const __dirname = path.dirname(__filename);
164177
165- module.exports = {
178+ export default {
166179 mode: 'development',
167180 entry: {
168181 index: {
@@ -216,9 +229,13 @@ The [`SplitChunksPlugin`](/plugins/split-chunks-plugin/) allows us to extract co
216229** webpack.config.js**
217230
218231``` diff
219- const path = require('path');
232+ import path from 'node:path';
233+ import { fileURLToPath } from 'node:url';
220234
221- module.exports = {
235+ const __filename = fileURLToPath(import.meta.url);
236+ const __dirname = path.dirname(__filename);
237+
238+ export default {
222239 mode: 'development',
223240 entry: {
224241 index: './src/index.js',
@@ -271,9 +288,13 @@ Before we start, let's remove the extra [`entry`](/concepts/entry-points/) and [
271288** webpack.config.js**
272289
273290``` diff
274- const path = require('path');
291+ import path from 'node:path';
292+ import { fileURLToPath } from 'node:url';
293+
294+ const __filename = fileURLToPath(import.meta.url);
295+ const __dirname = path.dirname(__filename);
275296
276- module.exports = {
297+ export default {
277298 mode: 'development',
278299 entry: {
279300 index: './src/index.js',
0 commit comments