正在显示
3 个修改的文件
包含
45 行增加
和
0 行删除
.env.production
0 → 100644
.eslintignore
0 → 100644
build/index.js
0 → 100644
1 | +const { run } = require('runjs') | ||
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 | +} |
-
请 注册 或 登录 后发表评论