@@ -41,6 +41,9 @@ This set of options is picked up by [webpack-dev-server](https://github.com/webp
4141
4242``` javascript
4343import path from " node:path" ;
44+ import { fileURLToPath } from " node:url" ;
45+ const __filename = fileURLToPath (import .meta.url);
46+ const __dirname = path .dirname (__filename );
4447
4548export default {
4649 // ...
@@ -877,6 +880,9 @@ You can also listen to a different socket with:
877880
878881` ` ` javascript
879882import path from "node:path";
883+ import { fileURLToPath } from "node:url";
884+ const __filename = fileURLToPath(import.meta.url);
885+ const __dirname = path.dirname(__filename);
880886
881887export default {
882888 // ...
@@ -1353,6 +1359,9 @@ It also allows you to set additional [TLS options](https://nodejs.org/api/tls.ht
13531359` ` ` javascript
13541360import fs from " node:fs" ;
13551361import path from " node:path" ;
1362+ import { fileURLToPath } from " node:url" ;
1363+ const __filename = fileURLToPath (import .meta.url);
1364+ const __dirname = path .dirname (__filename );
13561365
13571366export default {
13581367 // ...
@@ -1522,6 +1531,9 @@ Tell the server where to serve the content from. This is only necessary if you w
15221531
15231532` ` ` javascript
15241533import path from " node:path" ;
1534+ import { fileURLToPath } from " node:url" ;
1535+ const __filename = fileURLToPath (import .meta.url);
1536+ const __dirname = path .dirname (__filename );
15251537
15261538export default {
15271539 // ...
@@ -1539,6 +1551,9 @@ Provide an array of objects in case you have multiple static folders:
15391551
15401552` ` ` javascript
15411553import path from " node:path" ;
1554+ import { fileURLToPath } from " node:url" ;
1555+ const __filename = fileURLToPath (import .meta.url);
1556+ const __dirname = path .dirname (__filename );
15421557
15431558export default {
15441559 // ...
@@ -1588,6 +1603,9 @@ Tell the server at which URL to serve [`static.directory`](#directory) content.
15881603
15891604` ` ` javascript
15901605import path from " node:path" ;
1606+ import { fileURLToPath } from " node:url" ;
1607+ const __filename = fileURLToPath (import .meta.url);
1608+ const __dirname = path .dirname (__filename );
15911609
15921610export default {
15931611 // ...
@@ -1606,6 +1624,9 @@ Provide an array of objects in case you have multiple static folders:
16061624
16071625` ` ` javascript
16081626import path from " node:path" ;
1627+ import { fileURLToPath } from " node:url" ;
1628+ const __filename = fileURLToPath (import .meta.url);
1629+ const __dirname = path .dirname (__filename );
16091630
16101631export default {
16111632 // ...
@@ -1636,6 +1657,9 @@ Tell dev-server to use [`serveIndex`](https://github.com/expressjs/serve-index)
16361657
16371658` ` ` javascript
16381659import path from " node:path" ;
1660+ import { fileURLToPath } from " node:url" ;
1661+ const __filename = fileURLToPath (import .meta.url);
1662+ const __dirname = path .dirname (__filename );
16391663
16401664export default {
16411665 // ...
@@ -1670,6 +1694,9 @@ Tell dev-server to watch the files served by the [`static.directory`](#directory
16701694
16711695` ` ` javascript
16721696import path from " node:path" ;
1697+ import { fileURLToPath } from " node:url" ;
1698+ const __filename = fileURLToPath (import .meta.url);
1699+ const __dirname = path .dirname (__filename );
16731700
16741701export default {
16751702 // ...
@@ -1700,6 +1727,9 @@ It is possible to configure advanced options for watching static files from [`st
17001727
17011728` ` ` javascript
17021729import path from " node:path" ;
1730+ import { fileURLToPath } from " node:url" ;
1731+ const __filename = fileURLToPath (import .meta.url);
1732+ const __dirname = path .dirname (__filename );
17031733
17041734export default {
17051735 // ...
0 commit comments