forked from swift502/Sketchbook
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathwebpack.dev.js
More file actions
30 lines (27 loc) · 970 Bytes
/
webpack.dev.js
File metadata and controls
30 lines (27 loc) · 970 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
const { merge } = require("webpack-merge");
const common = require("./webpack.common.js");
const path = require("path");
const crypto = require("crypto");
// Calculate port based on directory path hash
function getPortFromPath(dirPath) {
const hash = crypto.createHash('md5').update(dirPath).digest('hex');
// Convert first 4 characters of hash to a number and map to port range 8000-9000
const hashValue = parseInt(hash.substring(0, 4), 16);
const port = 8000 + (hashValue % 1000);
return port;
}
const projectPort = getPortFromPath(__dirname);
console.log(`Using port ${projectPort} based on directory path: ${__dirname}`);
module.exports = merge(common, {
mode: "development",
devtool: "inline-source-map",
devServer: {
// progress: true,
liveReload: false,hot:false,
host: '0.0.0.0', // Allow access from any IP
port: projectPort,
static: {
directory: path.join(__dirname),
},
},
});