https://github.com/socheatsok78/generate-json-webpack-plugin
Webpack plugin to generate a JSON file
https://github.com/socheatsok78/generate-json-webpack-plugin
generate-json json webpack webpack-plugin
Last synced: 3 months ago
JSON representation
Webpack plugin to generate a JSON file
- Host: GitHub
- URL: https://github.com/socheatsok78/generate-json-webpack-plugin
- Owner: socheatsok78
- License: mit
- Created: 2020-05-14T07:59:33.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2023-03-04T18:27:45.000Z (over 3 years ago)
- Last Synced: 2026-04-07T16:36:26.366Z (3 months ago)
- Topics: generate-json, json, webpack, webpack-plugin
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/@pp-spaces/generate-json-webpack-plugin
- Size: 584 KB
- Stars: 1
- Watchers: 0
- Forks: 1
- Open Issues: 10
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# generate-json-webpack-plugin
Webpack plugin to generate a JSON file
[![NPM Download][npm-dl-badge]][npm-url]
[![NPM][npm-badge]][npm-url]
[![Webpack Build Test][github-action-badge]][github-action-url]
## Getting Started
To begin, you'll need to install `generate-json-webpack-plugin`:
```sh
$ npm install @pp-spaces/generate-json-webpack-plugin --save-dev
```
Then add the plugin to your webpack config. For example:
`webpack.config.js`
```js
const GenerateJsonPlugin = require('@pp-spaces/generate-json-webpack-plugin');
module.exports = {
plugins: [new GenerateJsonPlugin({
filename: 'manifest.json',
value: {
short_name: 'Weather',
name: 'Weather: Do I need an umbrella?',
description: 'Weather forecast information',
icons: [
{
src: "/images/icons-192.png",
type: "image/png",
sizes: "192x192"
},
{
src: "/images/icons-512.png",
type: "image/png",
sizes: "512x512"
}
],
start_url: "/?source=pwa",
background_color: "#3367D6",
display: "standalone",
scope: "/",
theme_color: "#3367D6"
}
})],
};
```
That will generate a file that looks like this:
`manifest.json`
```json
{
"short_name": "Weather",
"name": "Weather: Do I need an umbrella?",
"description": "Weather forecast information",
"icons": [
{
"src": "/images/icons-192.png",
"type": "image/png",
"sizes": "192x192"
},
{
"src": "/images/icons-512.png",
"type": "image/png",
"sizes": "512x512"
}
],
"start_url": "/?source=pwa",
"background_color": "#3367D6",
"display": "standalone",
"scope": "/",
"theme_color": "#3367D6"
}
```
### Options
| Name | Type | Default | Description |
| -------- | ------ | ------------- | ---------------- |
| filename | string | manifest.json | Output file name |
| source | string | \[Optional\] | Path to an existing JS/JSON file to extend |
| value | object | {} | Object to output or the properties you wish to modify |
| space | number | \[Optional\] | Insert white space into the output JSON string for readability purposes |
See [`tests/webpack.config.js`](tests/webpack.config.js) for more.
## License
[MIT](LICENSE)
[github-action-badge]: https://github.com/socheatsok78/generate-json-webpack-plugin/workflows/Webpack%20Build%20Test/badge.svg
[github-action-url]: https://github.com/socheatsok78/generate-json-webpack-plugin/actions?query=workflow%3A%22Webpack+Build+Test%22
[npm-url]: https://www.npmjs.com/package/@pp-spaces/generate-json-webpack-plugin
[npm-badge]: https://badgen.net/npm/v/@pp-spaces/generate-json-webpack-plugin
[npm-dl-badge]: https://img.shields.io/npm/dm/@pp-spaces/generate-json-webpack-plugin