Run a script (like postinstall) after npm installing a single package?

前端 未结 3 1692
甜味超标
甜味超标 2020-12-03 16:15

I\'m starting to play around with Snowpack. It takes a different approach from Webpack by bundling individual packages right after they\'re installed.

The \"issue\"

3条回答
  •  佛祖请我去吃肉
    2020-12-03 17:02

    I think the best bet would be to create a new script that performs the desired action. Something along the following lines in your package.json:

    {
      "scripts": {
        "snowpack-install" : "npm install --save && npx snowpack"
      }
    }
    

    Correction

    You can actually use the postinstall option in package.json. The postinstall will run "AFTER the package is installed". This would look something like the following:

    {
      "scripts": {
        "postinstall" : "npx snowpack"
      }
    }
    

提交回复
热议问题