Updating file references in a json file via a grunt task

前端 未结 3 580
无人共我
无人共我 2021-02-04 07:15

I\'m a JavaScript developer and fairly new to creating a build process from scratch. I chose to use Grunt for my current project and have created a GruntFile that does about 90%

3条回答
  •  南方客
    南方客 (楼主)
    2021-02-04 07:20

    I do something similar - you can load your manifest, update the contents then serialize it out again. Something like:

    grunt.registerTask('fixmanifest', function() {
         var tmpPkg = require('./path/to/manifest/manifest.json');
    
         tmpPkg.foo = "bar";
         fs.writeFileSync('./new/path/to/manifest.json', JSON.stringify(tmpPkg,null,2));
    });
    

提交回复
热议问题