-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.config.js
More file actions
88 lines (83 loc) · 2.5 KB
/
webpack.config.js
File metadata and controls
88 lines (83 loc) · 2.5 KB
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
const path = require('path');
const webpack = require("webpack");
const os = require('os');
const ifaces = os.networkInterfaces();
module.exports = env =>{
let devtool = env && env.production ? undefined : "source-map";
let mode = env && env.production ? 'production' : 'development';
let ip = undefined;
let port = "8081";
Object.keys(ifaces).forEach(function (ifname) {
for (const iface of ifaces[ifname]) {
if ('IPv4' !== iface.family || iface.internal !== false) {
// skip over internal (i.e. 127.0.0.1) and non-ipv4 addresses
continue;
}
if (!ip) {
ip = iface.address;
if (!env || !env.production) console.log(ip);
}
break;
}
});
ip = ip || "0.0.0.0";
let root = env && env.production ? "" : `http://${ip}:${port}/`;
return {
entry: {
index: './src/viewer/index/index.ts',
member: './src/viewer/index/member.ts',
playlist: './src/viewer/index/playlist.ts',
watch: './src/viewer/watch/watch.ts',
download: './src/viewer/download/download.ts',
},
optimization: {
splitChunks: {
cacheGroups: {
common: {
name: 'common',
chunks: 'initial',
priority: 2,
minChunks: 2,
},
},
},
},
devtool: devtool,
mode: mode,
module: {
rules: [
{
test: /\.tsx?$/,
use: 'ts-loader',
exclude: [/node_modules/, /server/],
},
],
},
plugins: [
new webpack.DefinePlugin({
'serverConfig': {
'apiRoot': JSON.stringify(root),
'repoRoot': JSON.stringify(root),
},
})
],
resolve: {
modules: ["src", "node_modules"],
extensions: ['.ts', '.js', '.html'],
},
output: {
path: path.resolve(__dirname, '.'),
filename: 'dist/[name].js'
},
externals: {},
devServer: {
publicPath: "/",
contentBase: "./static",
host: ip,
open: true,
hot: true,
compress: true,
port: 9000,
},
};
}