My goal is to create a customized `manifest.json` file for Chrome extensions in a more efficient, programmatic manner. Utilizing npm for dependency management, I've noticed that the `package.json` shares key fields with the `manifest.json`, such as "name," "description," and "version."
Is there a way to define a partial `manifest.json` file that contains only the Chrome-specific details and dynamically populates shared values from the `package.json`? In my experience, achieving this using Gulp is quite simple:
var gulp = require('gulp');
var fs = require('fs');
var jeditor = require('gulp-json-editor');
gulp.task('manifest', function() {
var pkg = JSON.parse(fs.readFileSync('./package.json'));
gulp.src('./manifest.json')
.pipe(jeditor({
'name': pkg.name,
'description': pkg.description,
'version': pkg.version,
'author': pkg.author,
'homepage_url': pkg.homepage,
}))
.pipe(gulp.dest("./dist"));
});
If there's a specific npm package designed for this task, or if someone can provide a general explanation of how it could be accomplished, I would greatly appreciate it. I am aware of Webpack 2's json loader feature, but I'm unsure of its application in scenarios like this.