vuejs / vue-cli

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

Tasks UI does not trigger `PRE` tasks from package.json #5453

Open APinchofDill opened 4 years ago

APinchofDill commented 4 years ago

Version

4.3.1

Reproduction link

https://github.com/dylanharty/vue-issue-pre

Environment info

  System:
    OS: Windows 10 10.0.18363
    CPU: (8) x64 Intel(R) Core(TM) i7-6820HK CPU @ 2.70GHz
  Binaries:
    Node: 12.16.3 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.22.4 - C:\Program Files (x86)\Yarn\bin\yarn.CMD
    npm: 6.14.4 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Edge: 44.18362.449.0
  npmPackages:
    @vue/babel-helper-vue-jsx-merge-props:  1.0.0
    @vue/babel-plugin-transform-vue-jsx:  1.1.2
    @vue/babel-preset-app:  4.3.1
    @vue/babel-preset-jsx:  1.1.2
    @vue/babel-sugar-functional-vue:  1.1.2
    @vue/babel-sugar-inject-h:  1.1.2
    @vue/babel-sugar-v-model:  1.1.2
    @vue/babel-sugar-v-on:  1.1.2
    @vue/cli-overlay:  4.3.1
    @vue/cli-plugin-babel: ~4.3.0 => 4.3.1
    @vue/cli-plugin-eslint: ~4.3.0 => 4.3.1
    @vue/cli-plugin-router: ~4.3.0 => 4.3.1
    @vue/cli-plugin-typescript: ~4.3.0 => 4.3.1
    @vue/cli-plugin-vuex: ~4.3.0 => 4.3.1
    @vue/cli-service: ~4.3.0 => 4.3.1
    @vue/cli-shared-utils:  4.3.1 (3.12.1)
    @vue/component-compiler-utils:  3.1.2
    @vue/eslint-config-typescript: ^5.0.2 => 5.0.2
    @vue/preload-webpack-plugin:  1.1.1
    @vue/web-component-wrapper:  1.2.0
    eslint-plugin-vue: ^6.2.2 => 6.2.2
    typescript: ~3.8.3 => 3.8.3
    vue: ^2.6.11 => 2.6.11
    vue-class-component: ^7.2.3 => 7.2.3
    vue-cli-plugin-pwa: ~1.0.0-alpha.1 => 1.0.0-alpha.1
    vue-eslint-parser:  7.0.0
    vue-hot-reload-api:  2.3.4
    vue-loader:  15.9.2
    vue-property-decorator: ^8.4.1 => 8.4.2
    vue-router: ^3.1.6 => 3.1.6
    vue-style-loader:  4.1.2
    vue-template-compiler: ^2.6.11 => 2.6.11
    vue-template-es2015-compiler:  1.9.1
    vuex: ^3.1.3 => 3.3.0

Steps to reproduce

  1. vue ui (start interface)
  2. Create a new project in the UI interface
  3. Add preserve and prebuild tasks
  4. Run serve or build, pre tasks do not run

What is expected?

Upon triggering a "serve" or "build" tasks any task labelled preserve/prebuild respectively should trigger.

What is actually happening?

preserve/prebuild tasks do not trigger.


A script in our app is required to run before each serve/build to generate some data before webpack starts for the application. The bug is that they do not run at all from the UI. yarn serve/yarn build works fine.

Maybe in a future release have the preserve and prebuild tasks live under serve and build tasks and toggle them.

jeneser commented 4 years ago

npm scripts supports pre and post hooks. They are automatically run by npm before (pre) and after (post) their respectively script/command. But cli-ui does not use npm/yarn command to execute script. All of the hooks are invalid. @sodatea Can we just use npm/yarn to execute the command? like this:

execa(<npm/yarn>, ['run', <task.name>], {...})
haoqunjiang commented 4 years ago

Yeah, if it does not break existing use cases, we can make that change.