[英]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. 我们在项目中使用带有Typescript的React。 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.
我们需要显示插件信息,例如插件的版本,git url,package.json中的插件自述文件,并在网页上显示。 And also we have to update the page when ever package.json is updated.
而且,当package.json更新时,我们也必须更新页面。
You can import package.json
of plugin and inspect it as a JavaScript object: 您可以导入插件的
package.json
并将其作为JavaScript对象进行检查:
// tslint:disable-next-line
const pkg = require('plugin/package.json');
console.log(pkg.description);
console.log(pkg.repository.url);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.