orc-scripts 2.0.0-dev.2 → 2.0.0-dev.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/config/webpack.config.js +0 -1
- package/src/scripts/start.js +12 -22
package/package.json
CHANGED
package/src/scripts/start.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const
|
|
1
|
+
const DevServer = require("webpack-dev-server");
|
|
2
2
|
const webpack = require("webpack");
|
|
3
3
|
|
|
4
4
|
const HOST = process.env.HOSTNAME || "localhost";
|
|
@@ -9,37 +9,27 @@ const PORT = argPort || process.env.PORT || 5000;
|
|
|
9
9
|
|
|
10
10
|
const config = require("../config/webpack.config.js");
|
|
11
11
|
const options = {
|
|
12
|
-
contentBase: "./dist",
|
|
13
|
-
publicPath: process.env.WEBPACK_PUBLIC_PATH || "/",
|
|
14
12
|
historyApiFallback: true,
|
|
15
|
-
|
|
13
|
+
hot: "only",
|
|
16
14
|
port: PORT,
|
|
17
15
|
host: HOST,
|
|
16
|
+
static: './dist',
|
|
17
|
+
devMiddleware: {
|
|
18
|
+
publicPath: process.env.WEBPACK_PUBLIC_PATH || "/",
|
|
19
|
+
},
|
|
18
20
|
};
|
|
19
21
|
|
|
20
22
|
if (HOST !== "localhost") {
|
|
21
23
|
options.public = HOST;
|
|
22
24
|
}
|
|
23
25
|
if (HOST !== "localhost" || args.indexOf("--https") !== -1 || process.env.HTTPS) {
|
|
24
|
-
options.
|
|
26
|
+
options.server = 'https';
|
|
25
27
|
}
|
|
26
28
|
|
|
27
|
-
const location = "http" + (options.https ? "s" : "") + "://" + HOST + ":" + PORT;
|
|
28
|
-
|
|
29
|
-
// /mockData/ contains json files to simulate API endpoints
|
|
30
|
-
options.before = (app, server) => {
|
|
31
|
-
app.get("/mockData/*", (req, res, next) => {
|
|
32
|
-
const parsedUrl = new URL(req.url, location);
|
|
33
|
-
parsedUrl.pathname = parsedUrl.pathname + ".json";
|
|
34
|
-
req.url = parsedUrl.href.replace(location, "");
|
|
35
|
-
next();
|
|
36
|
-
});
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
webpackDevServer.addDevServerEntrypoints(config, options);
|
|
40
29
|
const compiler = webpack(config);
|
|
41
|
-
const server = new webpackDevServer(compiler, options);
|
|
42
30
|
|
|
43
|
-
server
|
|
44
|
-
|
|
45
|
-
|
|
31
|
+
const server = new DevServer(options, compiler);
|
|
32
|
+
|
|
33
|
+
(async () => {
|
|
34
|
+
await server.start();
|
|
35
|
+
})();
|