Blame view

HHECS.Web/build/index.js 957 Bytes
胡菁 authored
1
2
3
4
5
const { run } = require("runjs");
const chalk = require("chalk");
const config = require("../vue.config.js");
const rawArgv = process.argv.slice(2);
const args = rawArgv.join(" ");
胡菁 authored
6
胡菁 authored
7
8
if (process.env.npm_config_preview || rawArgv.includes("--preview")) {
  const report = rawArgv.includes("--report");
胡菁 authored
9
胡菁 authored
10
  run(`vue-cli-service build ${args}`);
胡菁 authored
11
胡菁 authored
12
13
  const port = 9526;
  const publicPath = config.publicPath;
胡菁 authored
14
胡菁 authored
15
16
17
  var connect = require("connect");
  var serveStatic = require("serve-static");
  const app = connect();
胡菁 authored
18
19
20

  app.use(
    publicPath,
胡菁 authored
21
22
    serveStatic("./dist", {
      index: ["index.html", "/"],
胡菁 authored
23
    })
胡菁 authored
24
  );
胡菁 authored
25
26

  app.listen(port, function () {
胡菁 authored
27
28
29
    console.log(
      chalk.green(`> Preview at  http://localhost:${port}${publicPath}`)
    );
胡菁 authored
30
    if (report) {
胡菁 authored
31
32
33
34
35
      console.log(
        chalk.green(
          `> Report at  http://localhost:${port}${publicPath}report.html`
        )
      );
胡菁 authored
36
    }
胡菁 authored
37
  });
胡菁 authored
38
} else {
胡菁 authored
39
  run(`vue-cli-service build ${args}`);
胡菁 authored
40
}