简体   繁体   中英

How get plugin information from package.json, like about the plugin and license type etc using React (typescript)?

I have one requirement in my project.

We are using React with Typescript in our project. We need to show the plugin information like version of the plugin, git url,readme of plugin from package.json and have show on web page. And also we have to update the page when ever package.json is updated.

You can import package.json of plugin and inspect it as a JavaScript object:

// tslint:disable-next-line
const pkg = require('plugin/package.json');
console.log(pkg.description);
console.log(pkg.repository.url);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM