Skip to content

Commit e955832

Browse files
authored
Use local certs for webpack serve (#5460)
1 parent bbb1294 commit e955832

File tree

2 files changed

+21
-7
lines changed

2 files changed

+21
-7
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@
136136
"watch": "cross-env NODE_ENV=development ./node_modules/.bin/webpack --watch --progress",
137137
"build": "cross-env NODE_ENV=development ./node_modules/.bin/webpack --progress",
138138
"build:production": "yarn run clean && cross-env NODE_ENV=production ./node_modules/.bin/webpack --mode production",
139-
"serve": "yarn run clean && cross-env NODE_ENV=development WEBPACK_PUBLIC_PATH=https://localhost:5173/ webpack serve --progress --hot --server-type https"
139+
"serve": "yarn run clean && cross-env NODE_ENV=development USE_LOCAL_CERTS=true WEBPACK_PUBLIC_PATH=https://pterodactyl.test:5173/ webpack serve --progress --hot --server-type https"
140140
},
141141
"browserslist": [
142142
"> 0.5%",

webpack.config.js

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ module.exports = {
1818
path: path.join(__dirname, '/public/assets'),
1919
filename: isProduction ? 'bundle.[chunkhash:8].js' : 'bundle.[fullhash:8].js',
2020
chunkFilename: isProduction ? '[name].[chunkhash:8].js' : '[name].[fullhash:8].js',
21-
publicPath: (process.env.WEBPACK_PUBLIC_PATH || '/assets/'),
21+
publicPath: process.env.WEBPACK_PUBLIC_PATH || '/assets/',
2222
crossOriginLoading: 'anonymous',
2323
},
2424
module: {
@@ -77,7 +77,7 @@ module.exports = {
7777
test: /\.js$/,
7878
enforce: 'pre',
7979
loader: 'source-map-loader',
80-
}
80+
},
8181
],
8282
},
8383
stats: {
@@ -105,7 +105,13 @@ module.exports = {
105105
DEBUG: process.env.NODE_ENV !== 'production',
106106
WEBPACK_BUILD_HASH: Date.now().toString(16),
107107
}),
108-
new WebpackAssetsManifest({ output: 'manifest.json', writeToDisk: true, publicPath: true, integrity: true, integrityHashes: ['sha384'] }),
108+
new WebpackAssetsManifest({
109+
output: 'manifest.json',
110+
writeToDisk: true,
111+
publicPath: true,
112+
integrity: true,
113+
integrityHashes: ['sha384'],
114+
}),
109115
],
110116
optimization: {
111117
usedExports: true,
@@ -133,13 +139,21 @@ module.exports = {
133139
devServer: {
134140
compress: true,
135141
port: 5173,
142+
server: {
143+
type: 'https',
144+
options: process.env.USE_LOCAL_CERTS
145+
? {
146+
ca: path.join(__dirname, '../../docker/certificates/root_ca.pem'),
147+
cert: path.join(__dirname, '../../docker/certificates/pterodactyl.test.pem'),
148+
key: path.join(__dirname, '../../docker/certificates/pterodactyl.test-key.pem'),
149+
}
150+
: undefined,
151+
},
136152
static: {
137153
directory: path.join(__dirname, '/public'),
138154
publicPath: process.env.WEBPACK_PUBLIC_PATH || '/assets/',
139155
},
140-
allowedHosts: [
141-
'.pterodactyl.test',
142-
],
156+
allowedHosts: ['.pterodactyl.test'],
143157
headers: {
144158
'Access-Control-Allow-Origin': '*',
145159
},

0 commit comments

Comments
 (0)