{"_id":"fetch-write-webpack-plugin","_rev":"2-6f0e2f0a88203f5b393e8a78d0199965","name":"fetch-write-webpack-plugin","dist-tags":{"latest":"1.1.0"},"versions":{"1.0.1":{"name":"fetch-write-webpack-plugin","version":"1.0.1","description":"Webpack plugin that would fetch the data source and write file on build time 🚀","main":"dist/index.js","repository":{"type":"git","url":"git+https://github.com/anzai9/fetch-write-webpack-plugin.git"},"scripts":{"lint":"eslint '*/**/*.js' --quiet --fix","build":"babel lib/index.js --out-file dist/index.js","test:bundle":"npm run build && webpack --config ./webpack.config.test.js","semantic-release":"semantic-release","test":"echo skip"},"keywords":["webpack","node-fetch","json","plugin"],"author":{"name":"Chien-An Wang","email":"jiananwang1209@gamil.com"},"license":"ISC","dependencies":{"core-js":"^3.6.5","fs-extra":"^9.0.0","node-fetch":"^2.6.0"},"devDependencies":{"@babel/cli":"^7.8.4","@babel/core":"^7.9.0","@babel/plugin-proposal-class-properties":"^7.8.3","@babel/plugin-proposal-object-rest-spread":"^7.9.5","@babel/plugin-transform-regenerator":"^7.8.7","@babel/preset-env":"^7.9.5","@semantic-release/changelog":"^5.0.1","@semantic-release/git":"^9.0.0","babel-eslint":"^10.1.0","eslint":"^6.8.0","eslint-config-prettier":"^6.11.0","eslint-config-standard":"^14.1.1","eslint-plugin-import":"^2.20.2","eslint-plugin-node":"^10.0.0","eslint-plugin-prettier":"^3.1.3","eslint-plugin-promise":"^4.2.1","eslint-plugin-standard":"^4.0.1","husky":"^3.1.0","lint-staged":"^9.5.0","prettier":"^1.19.1","semantic-release":"^17.0.7","webpack":"^4.43.0","webpack-cli":"^3.3.11"},"husky":{"hooks":{"pre-commit":"lint-staged"}},"lint-staged":{"**/*.{js}":["prettier --write","eslint . --fix","git add"]},"gitHead":"5e0475988934bbdaedbd8c5d2440870fe0422ab4","bugs":{"url":"https://github.com/anzai9/fetch-write-webpack-plugin/issues"},"homepage":"https://github.com/anzai9/fetch-write-webpack-plugin#readme","_id":"fetch-write-webpack-plugin@1.0.1","_nodeVersion":"12.16.3","_npmVersion":"6.14.4","dist":{"integrity":"sha512-5utkVjVpCUqNOPGWotLizZaQk10im2+80muiSZdSgFUJgXhuDTqtsGroAalRj3ettovRWHNzpiculpA6wVTf1A==","shasum":"211aba3cf971d75e157c7dbec42999daca85d704","tarball":"https://registry.npmjs.org/fetch-write-webpack-plugin/-/fetch-write-webpack-plugin-1.0.1.tgz","fileCount":14,"unpackedSize":23397,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeqwQfCRA9TVsSAnZWagAAxCgQAKCAziRE/gAUvBZRpI+w\nVH5rshkLgmdtKIjGK+Cs00hvAzNc379FzAdnEHXHHaM8V9yQRlubDEfXO74E\nlMit7Sno4vsuOp0y/ySad6hn3u2a/K7m+83Du9CKkwi7EkqSnTAUklk05wn8\npDKcKmlI4iKFzyqcaDN79Y0lXiDJvPruWmGEwqKnypt0a/s6RM71KElzQuGu\n9m0cadq2g+bKWyvjUVUD7PaeVW58DlvsldwVla7I517xJxW1vhLpNuuRcWaF\n4Z8wHXQULFW0saZaN/g8eOvGkUtn5Xdh2/LnytGIXp+Ad8wUph/djgcelUcC\nzgcqnkCFyKrHY1+8Eh0fUNPtK6D/vmxdy25Z5+B2+DuTNGWyKeddPdYZ/vEa\npKle8OJNxzIfulayfFCtHjalcj3t9iHhVp/XIxT/6BuykKEcABeTvLIIIB6d\nJ3TzfeQ2kQxg2D+STqlNoonxDvEYtblzekztJ97A/Y65c9WJahje3EiIn9D0\nc4FXsMAH8ddV+o05MsgOEevL2Li/CGK2P+2wjAKC53nnpwAfYjsoZ65yU+3p\nqZODHywd6hovNMmrmelsZ642wiUbe9d9UibOpfO828RRatY7YmTHNLX9Pp5j\nkxvVEyR0DY8Nu2mxtufJ6IdcmNvM7SKMeOaWU+ESAZyOAtW9CGlqvk2OnhtQ\n1tBh\r\n=xj/2\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCS7ODbX6ndfhu9Jgq2f4gL41vZG6P1yrynb6/tG5W/rQIhAK4AvQm/QKdwv8zaRUGRHwW9X8X+HGj3AY36IREySOX1"}]},"maintainers":[{"name":"anzai9","email":"jiananwang1209@gmail.com"}],"_npmUser":{"name":"anzai9","email":"jiananwang1209@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/fetch-write-webpack-plugin_1.0.1_1588266015432_0.6327749244551741"},"_hasShrinkwrap":false},"1.1.0":{"name":"fetch-write-webpack-plugin","version":"1.1.0","description":"Webpack plugin that would fetch the data source and write file on build time 🚀","main":"dist/cjs.js","repository":{"type":"git","url":"git+https://github.com/anzai9/fetch-write-webpack-plugin.git"},"scripts":{"build:sample":"npm run clean -- static && npm run build && webpack --config ./example/webpack.config.js","build":"npm run clean -- dist && cross-env NODE_ENV=production babel lib -d dist --copy-files --verbose","lint:prettier":"prettier --write '*/**/*.js'","lint:eslint":"eslint '*/**/*.js' --quiet --fix --cache","lint":"npm-run-all -l -p \"lint:**\" --","security":"npm audit","clean":"del-cli","semantic-release":"semantic-release","test:only":"cross-env NODE_ENV=test jest","test:watch":"npm run test:only -- --watch","test:coverage":"npm run test:only -- --collectCoverageFrom=\"lib/**/*.js\" --coverage","test":"npm run test:coverage"},"keywords":["webpack","node-fetch","json","plugin"],"author":{"name":"Chien-An Wang","email":"jiananwang1209@gamil.com"},"license":"MIT","dependencies":{"fs-extra":"^9.0.0","node-fetch":"^2.6.0"},"devDependencies":{"@babel/cli":"^7.8.4","@babel/core":"^7.9.0","@babel/plugin-proposal-class-properties":"^7.8.3","@babel/plugin-proposal-object-rest-spread":"^7.9.6","@babel/plugin-transform-destructuring":"^7.9.5","@babel/plugin-transform-regenerator":"^7.8.7","@babel/plugin-transform-runtime":"^7.9.6","@babel/preset-env":"^7.9.5","@semantic-release/changelog":"^5.0.1","@semantic-release/git":"^9.0.0","babel-eslint":"^10.1.0","clean-webpack-plugin":"^3.0.0","cross-env":"^7.0.2","del-cli":"^3.0.0","eslint":"^6.8.0","eslint-config-prettier":"^6.11.0","eslint-config-standard":"^14.1.1","eslint-plugin-import":"^2.20.2","eslint-plugin-node":"^10.0.0","eslint-plugin-prettier":"^3.1.3","eslint-plugin-promise":"^4.2.1","eslint-plugin-standard":"^4.0.1","html-webpack-plugin":"^4.3.0","husky":"^3.1.0","jest":"^25.5.4","lint-staged":"^9.5.0","npm-run-all":"^4.1.5","prettier":"^1.19.1","semantic-release":"^17.0.7","webpack":"^4.43.0","webpack-cli":"^3.3.11"},"husky":{"hooks":{"pre-commit":"lint-staged"}},"lint-staged":{"*/**.js":["npm run lint","git add"]},"gitHead":"5516a4964a87a9bacf5998f366e0c97274cef695","bugs":{"url":"https://github.com/anzai9/fetch-write-webpack-plugin/issues"},"homepage":"https://github.com/anzai9/fetch-write-webpack-plugin#readme","_id":"fetch-write-webpack-plugin@1.1.0","_nodeVersion":"12.16.3","_npmVersion":"6.14.4","dist":{"integrity":"sha512-Qfwi7SffGMBl0A1h6CRXCIYe4Wwtlc8a0Q6WfAz8M2kPY9+cnV3U1uQbAFmmcMono//cig9eMVlVieTezksNzA==","shasum":"92323038c772eed3f338d0079ebaab2bf3064e53","tarball":"https://registry.npmjs.org/fetch-write-webpack-plugin/-/fetch-write-webpack-plugin-1.1.0.tgz","fileCount":5,"unpackedSize":16918,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJesAwYCRA9TVsSAnZWagAA3eUP/jyb9EVkQUEw13MlMgKf\nBquVKyyq0y/UMVPIQ3gauGWvFF/Gp0Zy739yfXUqfyrih7m4NHGYNVEkGCyX\nQenln/8eTFPtdAGtXYD89YjS7TLPi8ondqprnLAJX4S02UFh2CsDNPW2hrgm\n2YjRXPdxqmViyYnHi+eq7eut8510Ys8oOwxAEwFSRznRayG0+PGsSN5UlPoE\nyv2g+oXGYe7JjEiLJ2Z33PiQD4yWcbrv9LkIy0C73OUN9EZk5yXeexKYfzNC\nkXSfeDXw5Gwcnbz1qpO29BjpNnCfuQw4Yt+pLZfhBOjkxKg5Xhaj0ykjXuKr\n1H8AlHfKcc1M1Dd15gqPQvSGFGkzG7fk694PVWarhirxiqQ/gHMNH77K5HbE\n1ANUD+XxZoRAV+/Rp43OSQs58LQonf3FMc/oDowc1xSL3oR+rvI11HAGS/LO\n2smbgI7m6T644SlB4lwParhMa7ThtDUG8rFT+2k8PrVFr3ac/TTSo0WsTHYN\nErKSdlx7qGV/qOw1PAO32hXL2h5O87uryJ6S6zf8McRZpkupRTdPSECYMKtR\nhkK5fe6w3QB7T+sMXWGU8p394bDCN3Oh3JPcHl4rWLSRzXpXI6cUiG2wgndc\nhtdrUAAxo/f8LL9SjH23g2j1ZwRL4UGhy32DhYyxju5nYgZ8dT0XKpkV/iF/\nPBqm\r\n=6c4O\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIGfrAxaszfBKD/pdCJzMKbznS5aQUANkPFU9WTjNh08QAiBty6jJ5zzc6yBI5+eGaMVf7HrKTOh0Wlc698yehXZbWw=="}]},"maintainers":[{"name":"anzai9","email":"jiananwang1209@gmail.com"}],"_npmUser":{"name":"anzai9","email":"jiananwang1209@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/fetch-write-webpack-plugin_1.1.0_1588595736117_0.6208107104246925"},"_hasShrinkwrap":false}},"time":{"created":"2020-04-30T17:00:15.432Z","1.0.1":"2020-04-30T17:00:15.606Z","modified":"2022-05-02T07:54:50.830Z","1.1.0":"2020-05-04T12:35:36.218Z"},"maintainers":[{"name":"anzai9","email":"jiananwang1209@gmail.com"}],"description":"Webpack plugin that would fetch the data source and write file on build time 🚀","homepage":"https://github.com/anzai9/fetch-write-webpack-plugin#readme","keywords":["webpack","node-fetch","json","plugin"],"repository":{"type":"git","url":"git+https://github.com/anzai9/fetch-write-webpack-plugin.git"},"author":{"name":"Chien-An Wang","email":"jiananwang1209@gamil.com"},"bugs":{"url":"https://github.com/anzai9/fetch-write-webpack-plugin/issues"},"license":"MIT","readme":"<h1 style=\"text-align:center\">fetch-write-webpack-plugin</h1>\n<div style=\"text-align:center\">\n  <a href=\"https://www.npmjs.com/package/fetch-write-webpack-plugin\" target=\"_blank\">\n    <img alt=\"Version\" src=\"https://img.shields.io/npm/v/fetch-write-webpack-plugin.svg\">\n  </a>\n  <img alt=\"Version\" src=\"https://github.com/anzai9/fetch-write-webpack-plugin/workflows/Publish/badge.svg\">\n  <a href=\"https://github.com/anzai9/fetch-write-webpack-plugin/blob/master/LICENSE\" target=\"_blank\">\n    <img alt=\"License: MIT\" src=\"https://img.shields.io/github/license/anzai9/fetch-write-webpack-plugin\" />\n  </a>\n</div>\n\nWebpack plugin that would fetch the data source and write the file on build time 🚀\n\n## Install\n\n```sh\nnpm i -D fetch-write-webpack-plugin\n```\n\n```sh\nyarn add --dev fetch-write-webpack-plugin\n```\n\nThis is a [webpack](http://webpack.js.org/) plugin that could fetch the data on the other server and generate the corresponding files that you want bundle at the build time.\n\n## Usage\n\nThe plugin support fetch multiple data sources and build them each other before the compile.\n\nwebpack.config.js\n\n```javascript\nconst FetchWritePlugin = require('fetch-write-webpack-plugin')\n\nmodule.exports = {\n  entry: 'index.js',\n  output: {\n    path: __dirname + '/dist',\n    filename: 'index_bundle.js'\n  },\n  plugins: [\n    new FetchWritePlugin([\n      {\n        fetchOpts: {\n          url: 'http://localhost:4080/get/style',\n          retryOn: true,\n          headers: {\n            'Content-Type': 'application/json'\n          }\n        },\n        output: {\n          name: 'style.json',\n          basePath: './static/bundle'\n        }\n      },\n      {\n        fetchOpts: {\n          url: 'http://localhost:4080/get/name',\n          retryOn: true,\n          headers: {\n            'Content-Type': 'application/json'\n          }\n        },\n        output: {\n          name: 'name',\n          ext: 'json'\n        }\n      }\n    ])\n  ]\n}\n```\n\nThis will fetch to the data from `http://host/data/you/want` and generate the file at `./static/name.json`.\n\nIf you have multiple data sources and file you want to generate on run time, you could use an array to wrap all configure.\n\nWant to know more detail. [Ref](https://github.com/anzai9/fetch-write-webpack-plugin/blob/master/exapmle/webapck.config.js)\n\n## Options\n\n### The plugin's signature\n\n**webpack.config.js**\n\n```javasript\nmodule.exports = {\n  plugins: [new CopyPlugin([{fetchOpts, output}, ...])]\n}\n```\n\n### Fetch Options\n\n| Name       | Type      | Default     | Description                                        |     |\n| ---------- | --------- | ----------- | -------------------------------------------------- | --- |\n| url        | `string`  | `undefined` | data source's url                                  |     |\n| method     | `string`  | `GET`       | fetch method                                       |     |\n| headers    | `any`     | `undefined` | http headers                                       |     |\n| body       | `any`     | `undefined` | http body                                          |     |\n| retryOn    | `boolean` | `false`     | determine the retry fetch whether turn on or not   |     |\n| retries    | `number`  | `3`         | retry count only work while the retry on is `true` |     |\n| retryDelay | `number`  | `1000`      | retry delay only work while the retry on is `true` |     |\n\n### Output Options\n\n| Name     | Type     | Default               | Description           |\n| -------- | -------- | --------------------- | --------------------- |\n| name     | `string` | `undefined`           | filename              |\n| ext      | `string` | `undefined`           | file extension        |\n| basePath | `string` | `webapck output path` | output file base path |\n\n## Roadmap\n\n-   [ ] Add cache data while the the webpack dev-server hot reload\n-   [ ] Add force write featrue after emit hook and also compatible for the [`clean-webpack-plugin`](https://github.com/johnagan/clean-webpack-plugin)\n-   [ ] Compatible the writing file feature on [`webpack-dev-middleware`](https://github.com/webpack/webpack-dev-middleware) and [`webpack-dev-server`](https://github.com/webpack/webpack-dev-server) (TBD)\n-   [ ] Make example to the sandbox testing\n\n## Show your support\n\nGive a ⭐️ if this project helped you!\n\n## 📝 License\n\n[MIT](https://github.com/anzai9/fetch-write-webpack-plugin/blob/master/LICENSE) licensed.\n","readmeFilename":"README.md"}