【问题标题】:How to add custom script before build in react?如何在构建反应之前添加自定义脚本?
【发布时间】:2021-03-19 16:26:07
【问题描述】:

我正在使用的图表库有一个错误,为了解决这个问题,我应该运行这个脚本:https://github.com/plouc/nivo/blob/master/scripts/patch-react-spring.js。在构建之前。我曾想过添加“prebuild”:“npm run patch-react-spring.js”并在package.json下的根目录中添加patch-react-spring.js文件。但是,当我执行 npm run patch-react-app 或 npm run prebuild 时,我得到错误:npm ERR!缺少脚本:patch-react-spring.js

这是项目的 GitHub 存储库:https://github.com/JonasHendel/SunPosition

【问题讨论】:

    标签: javascript reactjs nivo-react


    【解决方案1】:

    你可以试试这个库

    https://www.npmjs.com/package/patch-package

    
        # fix a bug in one of your dependencies
        vim node_modules/some-package/brokenFile.js
        
        # run patch-package to create a .patch file
        npx patch-package some-package
        
        # commit the patch file to share the fix with your team
        git add patches/some-package+3.14.15.patch
        git commit -m "fix brokenFile.js in some-package"
    
    

    在 package.json 中

     "scripts": {
    "postinstall": "patch-package"
     }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-01-17
      • 2021-05-15
      • 2016-03-21
      • 2022-08-20
      • 2021-04-26
      • 2023-02-11
      • 2011-07-31
      • 2018-06-18
      相关资源
      最近更新 更多