|
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(" ");
|
|
6
|
|
|
7
8
|
if (process.env.npm_config_preview || rawArgv.includes("--preview")) {
const report = rawArgv.includes("--report");
|
|
9
|
|
|
10
|
run(`vue-cli-service build ${args}`);
|
|
11
|
|
|
12
13
|
const port = 9526;
const publicPath = config.publicPath;
|
|
14
|
|
|
15
16
17
|
var connect = require("connect");
var serveStatic = require("serve-static");
const app = connect();
|
|
18
19
20
|
app.use(
publicPath,
|
|
21
22
|
serveStatic("./dist", {
index: ["index.html", "/"],
|
|
23
|
})
|
|
24
|
);
|
|
25
26
|
app.listen(port, function () {
|
|
27
28
29
|
console.log(
chalk.green(`> Preview at http://localhost:${port}${publicPath}`)
);
|
|
30
|
if (report) {
|
|
31
32
33
34
35
|
console.log(
chalk.green(
`> Report at http://localhost:${port}${publicPath}report.html`
)
);
|
|
36
|
}
|
|
37
|
});
|
|
38
|
} else {
|
|
39
|
run(`vue-cli-service build ${args}`);
|
|
40
|
}
|