提交 | 用户 | 时间
|
0ca254
|
1 |
const { run } = require('runjs') |
A |
2 |
const chalk = require('chalk') |
|
3 |
const config = require('../vue.config.js') |
|
4 |
const rawArgv = process.argv.slice(2) |
|
5 |
const args = rawArgv.join(' ') |
|
6 |
|
|
7 |
if (process.env.npm_config_preview || rawArgv.includes('--preview')) { |
|
8 |
const report = rawArgv.includes('--report') |
|
9 |
|
|
10 |
run(`vue-cli-service build ${args}`) |
|
11 |
|
|
12 |
const port = 9526 |
|
13 |
const publicPath = config.publicPath |
|
14 |
|
|
15 |
var connect = require('connect') |
|
16 |
var serveStatic = require('serve-static') |
|
17 |
const app = connect() |
|
18 |
|
|
19 |
app.use( |
|
20 |
publicPath, |
|
21 |
serveStatic('./dist', { |
|
22 |
index: ['index.html', '/'] |
|
23 |
}) |
|
24 |
) |
|
25 |
|
|
26 |
app.listen(port, function () { |
|
27 |
console.log(chalk.green(`> Preview at http://localhost:${port}${publicPath}`)) |
|
28 |
if (report) { |
|
29 |
console.log(chalk.green(`> Report at http://localhost:${port}${publicPath}report.html`)) |
|
30 |
} |
|
31 |
|
|
32 |
}) |
|
33 |
} else { |
|
34 |
run(`vue-cli-service build ${args}`) |
|
35 |
} |