Skip to content

Commit ed29972

Browse files
use default port; use fewer webpack CLI options
1 parent d6c25cf commit ed29972

File tree

5 files changed

+18
-12
lines changed

5 files changed

+18
-12
lines changed

base-theme/assets/webpack/webpack.dev.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import "webpack-dev-server" // this import tells webpack's typings about the dev
88
import * as envalid from "envalid"
99

1010
const env = envalid.cleanEnv(process.env, {
11-
WEBPACK_PORT: envalid.port()
11+
WEBPACK_PORT: envalid.port({ default: 3001 })
1212
})
1313

1414
const devOverrides: Configuration = {
@@ -24,6 +24,11 @@ const devOverrides: Configuration = {
2424

2525
devServer: {
2626
port: env.WEBPACK_PORT,
27+
/**
28+
* Binding to "0.0.0.0" allows devices on the same network (e.g., a mobile
29+
* phone) to load the webpack assets.
30+
*/
31+
host: "0.0.0.0",
2732
hot: true,
2833
open: false,
2934
headers: {

base-theme/layouts/partials/webpack_url.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{{- $port := getenv "WEBPACK_PORT" -}}
1+
{{- $port := getenv "WEBPACK_PORT" | default 3001 -}}
22
{{- if or site.IsServer (not (eq site.BaseURL "")) -}}
33
{{- if or site.IsServer (in site.BaseURL ":3000") -}}
44
{{- if hasPrefix .url "/" -}}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"scripts": {
88
"lint": "eslint {base-theme,course,course-v2,fields,util,www,tests-e2e}",
99
"start": "echo \"Run 'npm run start:www' or 'npm run start:course'\"",
10-
"start:webpack": "dotenv -- webpack serve --config ./base-theme/assets/webpack/webpack.dev.ts --hot --host 0.0.0.0 --stats-children",
10+
"start:webpack": "dotenv -- webpack serve --config ./base-theme/assets/webpack/webpack.dev.ts",
1111
"start:www": "dotenv -- concurrently \"npm:start:webpack\" \"npm:start:www:hugo\" --kill-others",
1212
"start:course": "dotenv -- concurrently \"npm:start:webpack\" \"npm:start:course:hugo\" --kill-others",
1313
"start:fields": "dotenv -- concurrently \"npm:start:webpack\" \"npm:start:fields:hugo\" --kill-others",

playwright.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import * as envalid from "envalid"
66

77
dotenv.config()
88
const env = envalid.cleanEnv(process.env, {
9-
WEBPACK_PORT: envalid.port()
9+
WEBPACK_PORT: envalid.port({ default: 3001 })
1010
})
1111

1212
/**

tests-e2e/global-setup.ts

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,9 @@ import handler from "serve-handler"
99
import Table from "cli-table3"
1010
import * as color from "ansi-colors"
1111

12-
1312
dotenv.config()
1413
const env = envalid.cleanEnv(process.env, {
15-
WEBPACK_PORT: envalid.port()
14+
WEBPACK_PORT: envalid.port({ default: 3001 })
1615
})
1716

1817
const execSh = execShCb.promise
@@ -69,12 +68,14 @@ const setupTests = async () => {
6968
table.push([site.name, `http://localhost:${site.port}`])
7069
})
7170

72-
console.log([
73-
"\n",
74-
color.bold("Now serving the following sites:\n"),
75-
table.toString(),
76-
"\n"
77-
].join(""))
71+
console.log(
72+
[
73+
"\n",
74+
color.bold("Now serving the following sites:\n"),
75+
table.toString(),
76+
"\n"
77+
].join("")
78+
)
7879
}
7980

8081
export default setupTests

0 commit comments

Comments
 (0)