forked from Material-MADS/mads-app
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
58 lines (50 loc) · 2.74 KB
/
server.js
File metadata and controls
58 lines (50 loc) · 2.74 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
/*=================================================================================================
// Project: CADS/MADS - An Integrated Web-based Visual Platform for Materials Informatics
// Hokkaido University (2018-)
// Last Update: Q3 2023
// ________________________________________________________________________________________________
// Authors: Mikael Nicander Kuwahara (Lead Developer) [2021-]
// Jun Fujima (Former Lead Developer) [2018-2021]
// ________________________________________________________________________________________________
// Description: Webpack dev server
// ------------------------------------------------------------------------------------------------
// Notes: This is the development server that runs the main app
// ------------------------------------------------------------------------------------------------
// References: 'NodeJS' platform and 'WebPack' library
=================================================================================================*/
//-------------------------------------------------------------------------------------------------
// Load required libraries
//-------------------------------------------------------------------------------------------------
import webpack from 'webpack';
import WebpackDevServer from 'webpack-dev-server';
import config from './webpack.local.config';
//-------------------------------------------------------------------------------------------------
//-------------------------------------------------------------------------------------------------
// Setup Server environment
//-------------------------------------------------------------------------------------------------
const port = process.env.DEV_SERVER_PORT || 3000;
const devServerPublic = process.env.DEV_SERVER_PUBLIC_ORIGIN || '';
//-------------------------------------------------------------------------------------------------
//-------------------------------------------------------------------------------------------------
// Start Server
// (Ignore the deprecation warning regarding 'listen' in VSCode, it makes no sense and has no
// online explanation)
//-------------------------------------------------------------------------------------------------
new WebpackDevServer(webpack(config), {
publicPath: config[1].output.publicPath,
hot: true,
inline: true,
historyApiFallback: true,
headers: {
'Access-Control-Allow-Origin': '*',
},
port,
public: devServerPublic,
}).listen(port, '0.0.0.0', (err) => {
if (err) {
console.error(err);
}
console.log(`Listening at 0.0.0.0:${port}`);
console.log('publicPath:', config[1].output.publicPath);
});
//-------------------------------------------------------------------------------------------------