【问题标题】:npm scripts pass dynamic arguments from one script to the othernpm 脚本将动态参数从一个脚本传递到另一个脚本
【发布时间】:2020-07-31 16:03:15
【问题描述】:

如何将参数从一个脚本传递到另一个脚本 使用npm-run-all(并行运行)

scripts:{
   "start":"run-p dev watch -- --theme=$themeId",
   "dev": "webpack",
   "watch": "theme watch --env=$themeId"
}

然后像这样调用start:

npm run start theme=2233

但它不会将参数传递给watch 参数

【问题讨论】:

    标签: npm npm-scripts


    【解决方案1】:

    使用${npm_config_themeId}

      "scripts": {
        "start": "run-p dev watch",
        "watch": "theme watch --env=${npm_config_theme}",
      }
    

    然后调用 npm run start -theme=123

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-11-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-06-09
      相关资源
      最近更新 更多