vuejs / vue-cli

🛠️ webpack-based tooling for Vue.js Development
https://cli.vuejs.org/
MIT License
29.75k stars 6.32k forks source link

Does @vue/cli-service provide a way to call the JavaScript API to build? #7436

Open shendiid opened 10 months ago

shendiid commented 10 months ago

Version

3.11.0

Reproduction link

cli.vuejs.org

Environment info

Does @vue/cli-service provide a way to call the JavaScript API to build?

Steps to reproduce

Does @vue/cli-service provide a way to call the JavaScript API to build?

What is expected?

provide a way to call the JavaScript API to build

What is actually happening?

There is no way to build with JavaScript API

xiaodong2008 commented 10 months ago

Hi, why you need to call this in JavaScript api? Can you use exec or execSync to build with build command?

Try to use like this:

const {execSync} = require("child_process")

execSync("npm run build")
shendiid commented 10 months ago

Hi, why you need to call this in JavaScript api? Can you use exec or execSync to build with build command?

Try to use like this:

const {execSync} = require("child_process")

execSync("npm run build")

I need to flexibly perform packaging operations in the node environment

xiaodong2008 commented 10 months ago

Hi, why you need to call this in JavaScript api? Can you use exec or execSync to build with build command? Try to use like this:

const {execSync} = require("child_process")

execSync("npm run build")

I need to flexibly perform packaging operations in the node environment

Then why you can't use execSync to do build operations? I think this method is available for you :)

If you really have some problems with this method, can you tell me more about your usage?

shendiid commented 10 months ago

Hi, why you need to call this in JavaScript api? Can you use exec or execSync to build with build command? Try to use like this:

const {execSync} = require("child_process")

execSync("npm run build")

I need to flexibly perform packaging operations in the node environment

Then why you can't use execSync to do build operations? I think this method is available for you :)

If you really have some problems with this method, can you tell me more about your usage?

For example, I need to dynamically add or delete plugins

xiaodong2008 commented 10 months ago

Hi, why you need to call this in JavaScript api? Can you use exec or execSync to build with build command? Try to use like this:

const {execSync} = require("child_process")

execSync("npm run build")

I need to flexibly perform packaging operations in the node environment

Then why you can't use execSync to do build operations? I think this method is available for you :) If you really have some problems with this method, can you tell me more about your usage?

For example, I need to dynamically add or delete plugins

Then just npm i name && npm run build, there isn't any problem. You can do anything you want with child_process