I’m trying to run vue-cli-service serve
from inside a Node.js application like this:
JavaScript
x
7
1
const Service = require('@vue/cli-service');
2
const service = new Service(process.cwd());
3
service.init("development");
4
service.run('serve').then(({ server, url }) => {
5
console.log("started server on " + url);
6
});
7
And it works.
JavaScript
1
7
1
$ node e2e.js
2
INFO Starting development server
3
40% building 130/136 modules 6 active node_modules/eslint-loader/index.js??ref--13-0!/ui/src/js/config/Product.js
4
. . .
5
. . .
6
started server on http://localhost:8080/
7
But when I do it in production
mode (change service.init("development")
to service.init("production")
), I don’t see the webpack “building” progress anymore.
JavaScript
1
4
1
$ node e2e.js
2
INFO Starting development server
3
started server on http://localhost:8080/
4
Hence my question: how to start a Vue server in production mode, but keep webpack progress printed to the console?
Advertisement
Answer
Progress is reported by Webpack’s ProgressPlugin
, which Vue CLI inserts only for non-production and non-test builds (since 3.x).
You could enable this plugin in <root>/vue.config.js
with devServer.progress=true
(currently undocumented):
JavaScript
1
6
1
module.exports = {
2
devServer: {
3
progress: true // always show progress (even in production mode)
4
}
5
}
6
Or in your e2e.js
, you could insert the ProgressPlugin
into the Service
instance’s webpackChainFns[]
after init()
:
JavaScript
1
7
1
service.init("production")
2
service.webpackChainFns.push(config => {
3
config
4
.plugin("progress")
5
.use(require("webpack/lib/ProgressPlugin"))
6
})
7