{"_id":"write-file-webpack","_rev":"2-9e4a4fb45d9325965d8101f7cfd0d720","name":"write-file-webpack","dist-tags":{"latest":"1.0.1"},"versions":{"1.0.0":{"name":"write-file-webpack","version":"1.0.0","description":"[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)","main":"index.js","repository":{"type":"git","url":"git+https://github.com/Gyumeijie/write-file-webpack.git"},"keywords":["webpack","webpack v3","write","file","plugin","webpack-plugin"],"scripts":{"start":"webpack --config example/webpack.config.js"},"author":{"name":"Gyumeijie"},"license":"MIT","homepage":"https://github.com/Gyumeijie/write-file-webpack#readme","devDependencies":{"webpack":"^3.6.0"},"gitHead":"04646d2c28840c3225d7c84447ea24ccdd199639","bugs":{"url":"https://github.com/Gyumeijie/write-file-webpack/issues"},"_id":"write-file-webpack@1.0.0","_npmVersion":"5.5.1","_nodeVersion":"9.0.0","_npmUser":{"name":"gyumeijie","email":"Gyumeijie@gmail.com"},"dist":{"integrity":"sha512-mqkdenKG0otHRfBIAdCCdAU9oDoZiE0dim9aco5np6ED7XrxBjPJLlhXtDh47iWBOIiS2KSTjhDz1D7YaFt1nQ==","shasum":"8f7f51fd210adc7409e34066c7dbd3c143d7fe90","tarball":"https://registry.npmjs.org/write-file-webpack/-/write-file-webpack-1.0.0.tgz","fileCount":3,"unpackedSize":6285,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJbxr3qCRA9TVsSAnZWagAA3rUP/3+0/auV8OHTGdUn2PLw\nEg3wH3H6AMWkCT/LxicYI78Z183GBgjFKq0l8lha33whPGF0qDS0u/F3n0f8\nPvy0+TqaPhQbVAj1Yke9ZGmAsFVNxFcHVpVrHP7/aVC9YNPyKBOKwNR+HIfk\nC1hAiMQxXrD4U3sSFzyn2urEa2gh6T2FSldJ5286HGqN0DR2fSG1E9YiDBdF\nBOMsoS5MqD3FLurc2UUTT3IShRx7Gn2CT7fX/plgAkYNP3+bFJp9RZYULSPy\nzF1aRFXr4MBhFLtQEZ6+iIHIqzEJ9IW1b+uvbV0XXMSs8GKQ1wa9FJMMR3MU\nCE5Or23zbuq/DefvC73C4Lr0rmF60qF8U/lDGzFhSIUHJQtV9ccGX8fm9Z5z\nnI9blPsqgXqNcPus1gfiZu9sy4SjtFyVfo+x/ikzubF397WmSJURPLxHx/em\nHCDEnPxygejlk6qT8ZjLWj6QB3rLqDdjDj1YNcEUEO6FI6Iz3TqE+3dFrpS9\nSDAyqp9H9L9qnbcRRcM5x7cRJwE3AeJ+Czxt62V/t0epAi5r7zEN5C+5tWYv\nvdEyf761qWswVGfvXrnp8fnmAOJzVDnDM3NUT5ZipB0W+6DDzY4O0GZXhF40\n3rs0sDALA5fiFkx3HdbynnZS7tqlBu+2HExtwQTl+L1yMertxiKlC+oVwjmQ\nKV1/\r\n=vqrh\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDNFUutm6UQ4PJ0SrmxFnfNtDJ6KHSICQS4twvnJ8+3OwIhAL39psanwML6wNfycipDQ7LQHju6sxN/kEb0jiOiPtfH"}]},"maintainers":[{"name":"gyumeijie","email":"Gyumeijie@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/write-file-webpack_1.0.0_1539751402166_0.9276782924942164"},"_hasShrinkwrap":false},"1.0.1":{"name":"write-file-webpack","version":"1.0.1","description":"[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)","main":"index.js","repository":{"type":"git","url":"git+https://github.com/Gyumeijie/write-file-webpack.git"},"keywords":["webpack","webpack v3","write","file","plugin","webpack-plugin"],"scripts":{"start":"webpack --config example/webpack.config.js"},"author":{"name":"Gyumeijie"},"license":"MIT","homepage":"https://github.com/Gyumeijie/write-file-webpack#readme","devDependencies":{"webpack":"^3.6.0"},"gitHead":"970ccfdb6afb8e7bead9cb9c715220023538205a","bugs":{"url":"https://github.com/Gyumeijie/write-file-webpack/issues"},"_id":"write-file-webpack@1.0.1","_npmVersion":"5.5.1","_nodeVersion":"9.0.0","_npmUser":{"name":"gyumeijie","email":"Gyumeijie@gmail.com"},"dist":{"integrity":"sha512-2D4G9s0OmYi2an+kAk/90YtUgeJtx3Qk3L+iniuKveRMOSgQC+gmpDGTYT0jh+tem0OIDrQQ8yIodPW5b+8Utg==","shasum":"b6e08220ce6f1bdce4cb2ff79a695f29c41fd132","tarball":"https://registry.npmjs.org/write-file-webpack/-/write-file-webpack-1.0.1.tgz","fileCount":3,"unpackedSize":6385,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJbxsDDCRA9TVsSAnZWagAAIFwQAI0AHXNo9SYcptvkhYHW\nRM/dlkwhv3wZ5IW28E0KNpax7rPG7BRAbPd6OQ9GkfEvvPIfL7rY/l9weS0h\nYs80TW/GgW2+0x4PyoQSG+UuhyGXF5jq1tySkSgy3qT8+h35L6ixU3coqEtT\nrjXqGdfwf0g42VG28EsFrfBR5XabwaXulrnNteO0R+LyZ/C1EH0UNx8A2Ind\n/XhNuppDrA13NjzdblTra3cswWvNGfikE6zV9ibq9eJK7RUSPv4A+sCQq9xz\nFF6ofYTO+p/pAzILhFJ5l3Qs37MqeQJ3g6LNpgEyVb5QMTQqAaaIF9H8jZ9q\nMFDV2iY+YyeQYDPt7WSN43P1hNv6s4el4jZw5Ih+t31RBdDbBvB4CREKZOtF\nhPXsOJ1N0QV0QnFVmRBwMBq7wvmCfJori7gL83eM5f1O8Hor+XCo6vVrbQUG\nEuQxe1nzuOtblqqA70deQZ59IU31XYgvxwyqMRdt0Y5s2cQnuoXB/iarH0Sp\nFLsl9N5+TFn5rn0ZwHDPRL4u3t8KwJaQoB/245e7AZcv3dL8Ur9RxqeUl5wX\n9EkP+y8+AMKqtocKsLy27Bdn6ubEkDPNuOqU/yMsJtq8Bqm47KhzBgphmudw\niQBbCuu2KqcNw0UZnJEMe/INPGZqd6kw9XxYWWOFTOMTJNlp6RXmG6pdssu5\nOkPh\r\n=h1pn\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCWq+uKua6Jbas43uMb9lgvAR9dePOVEReg2mPi3YRwaAIgeYKzPy0aBk7Bk77Bd/rzhbpZiiQkK1EqsaY9jQBPiAA="}]},"maintainers":[{"name":"gyumeijie","email":"Gyumeijie@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/write-file-webpack_1.0.1_1539752130696_0.5305920607796495"},"_hasShrinkwrap":false}},"time":{"created":"2018-10-17T04:43:22.165Z","1.0.0":"2018-10-17T04:43:22.325Z","modified":"2022-05-24T18:14:59.273Z","1.0.1":"2018-10-17T04:55:30.835Z"},"maintainers":[{"name":"gyumeijie","email":"Gyumeijie@gmail.com"}],"description":"[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)","homepage":"https://github.com/Gyumeijie/write-file-webpack#readme","keywords":["webpack","webpack v3","write","file","plugin","webpack-plugin"],"repository":{"type":"git","url":"git+https://github.com/Gyumeijie/write-file-webpack.git"},"author":{"name":"Gyumeijie"},"bugs":{"url":"https://github.com/Gyumeijie/write-file-webpack/issues"},"license":"MIT","readme":"# Write to file plugin for webpack(v3)\n[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)\n\nThis is a simple webpack plugin for writing data to file. And there is a similar [plugin](https://github.com/Gyumeijie/write-to-file-webpack) for webpack v4.\n\n# Features\n1. support creating directory recursively\n2. support data of function type, which allows processing data in complex situation\n3. support native options of underlying writeFileSync\n4. support protection of an exsited file\n\n# Installation\n`npm install --save-dev write-file-webpack`\n\n# Usage\nThe data to be written can be either a simple javascript variable, or a function which returns some data. \n\n```javascript\nconst WriteToFilePlugin = require('write-file-webpack');\n\nmodule.exports = {\n  ...\n  plugins: [\n     new WriteToFilePlugin({ \n        filename: 'path/to/write/file', \n        data: 'console.log(\"write to file\")'\n      })\n  ]\n  ...\n}\n```\n\n```javascript\nconst WriteToFilePlugin = require('write-file-webpack');\n\nmodule.exports = {\n   ...\n   plugins: [\n      new WriteToFilePlugin({ \n         filename: 'path/to/write/file', \n         data: function () {\n            return \"console.log('write to file')\"\n         }\n     })\n   ]\n   ...\n}\n```\n\nIf the `data` is provided as a `function`, we can do more operations than just simply returning the data to be written. For example, if we wanna write to a file parts of an exsited file say `package.json`, and more specifically, removing the `dependencies` and `devDependencies` items, with `write-file-webpack` we can do this:\n\n```javascript\nconst WriteToFilePlugin = require('write-file-webpack');\nconst config = require('./package.json');\n\nmodule.exports = {\n   ...\n   plugins: [\n      new WriteToFilePlugin({ \n         filename: 'path/to/write/package.json', \n         data: function () {\n            return JSON.stringify({\n               ...config,\n               dependencies: undefined,\n               devDependencies: undefined,\n           });\n         }\n     })\n   ]\n   ...\n}\n```\nOf course, if we want to copy the whole content of a existed file, there is webpack plugin called `copy-webpack-plugin`.\n\n# Support\n`node >= 6` and `webpack v3`\n\n# Options\n- filename (**required**)\n- data (**required**)\n- override          \n`<boolean> Default: true`, if set to false, no data will be written to an exsited file \n- encoding     \n`<string> | <null> Default: 'utf8'`\n- mode       \n`<integer> Default: 0o666`\n- flag        \n`<string> Default: 'w'`\n\nFor more information about `encoding`, `mode`, and `flag` please refer to [node writeFile](https://nodejs.org/docs/latest-v9.x/api/fs.html#fs_fs_writefilesync_file_data_options).\n","readmeFilename":"README.md"}