[removed] get package.json data in gulpfile.js

前端 未结 4 1225
时光说笑
时光说笑 2020-12-07 19:44

Not a gulp-specific question per-se, but how would one get info from the package.json file within the gulpfile.js; For instance, I want to get the homepage or the name and u

4条回答
  •  离开以前
    2020-12-07 20:08

    If you are triggering gulp from NPM, like using "npm run build" or something

    (This only works for gulp run triggers by NPM)

    process.env.npm_package_Object

    this should be seprated by underscore for deeper objects.

    if you want to read some specific config in package.json like you want to read config object you have created in package.json

    scripts : {
       build: gulp 
    },
    config : {
       isClient: false.
    }
    

    then you can use

    process.env.npm_package_**config_isClient**
    

提交回复
热议问题