{"id":18067533,"url":"https://github.com/lependu/fastify-webpack-hmr","last_synced_at":"2025-04-11T21:20:41.743Z","repository":{"id":32962603,"uuid":"147951847","full_name":"lependu/fastify-webpack-hmr","owner":"lependu","description":"Webpack hot module reloading for Fastify","archived":false,"fork":false,"pushed_at":"2023-04-06T17:10:54.000Z","size":56,"stargazers_count":29,"open_issues_count":6,"forks_count":5,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-25T17:16:15.510Z","etag":null,"topics":["fastify","fastify-plugin","hmr","webpack"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lependu.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-09-08T16:47:13.000Z","updated_at":"2024-05-02T19:33:42.000Z","dependencies_parsed_at":"2024-06-18T21:23:59.410Z","dependency_job_id":"4389b569-c4f3-4775-92b2-6f936d58106d","html_url":"https://github.com/lependu/fastify-webpack-hmr","commit_stats":{"total_commits":65,"total_committers":4,"mean_commits":16.25,"dds":0.1384615384615384,"last_synced_commit":"a40e49dbc925edce8939ce0a7c85aa950bff5bb2"},"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lependu%2Ffastify-webpack-hmr","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lependu%2Ffastify-webpack-hmr/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lependu%2Ffastify-webpack-hmr/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lependu%2Ffastify-webpack-hmr/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lependu","download_url":"https://codeload.github.com/lependu/fastify-webpack-hmr/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248173826,"owners_count":21059594,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["fastify","fastify-plugin","hmr","webpack"],"created_at":"2024-10-31T07:09:40.561Z","updated_at":"2025-04-11T21:20:41.720Z","avatar_url":"https://github.com/lependu.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"# fastify-webpack-hmr\n\n[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat)](http://standardjs.com/)\n[![Build Status](https://travis-ci.org/lependu/fastify-webpack-hmr.svg?branch=master)](https://travis-ci.org/lependu/fastify-webpack-hmr)\n[![Known Vulnerabilities](https://snyk.io/test/github/lependu/fastify-webpack-hmr/badge.svg)](https://snyk.io/test/github/lependu/fastify-webpack-hmr)\n[![Coverage Status](https://coveralls.io/repos/github/lependu/fastify-webpack-hmr/badge.svg?branch=master)](https://coveralls.io/github/lependu/fastify-webpack-hmr?branch=master)\n![npm (scoped)](https://img.shields.io/npm/v/fastify-webpack-hmr/latest)\n![npm](https://img.shields.io/npm/dm/fastify-webpack-hmr.svg)\n\nInspired by [koa-webpack](https://github.com/shellscape/koa-webpack) plugin.  \nUnder the hood it sets up [webpack-dev-middleware](https://github.com/webpack/webpack-dev-middleware) and [webpack-hot-middleware](https://github.com/webpack-contrib/webpack-hot-middleware).\n\n## Install\n```\n$ npm i --save-dev fastify-webpack-hmr\n```\n\n## Versions\n\nThe plugin supports the following `Fastify` and `Webpack` versions. Please refer to corresponding branch in PR and issues.\n\nversion | branch | fastify | webpack | end of support\n--------|--------|---------|------------|--------  \n1.x | [1.x](https://github.com/lependu/fastify-webpack-hmr/tree/1.x) | [1.x](https://github.com/fastify/fastify/tree/1.x) | [4.x](https://github.com/webpack/webpack/tree/webpack-4) | EOL \n2.x | [2.x](https://github.com/lependu/fastify-webpack-hmr/tree/2.x) | [2.x](https://github.com/fastify/fastify/tree/2.x) | [4.x](https://github.com/webpack/webpack/tree/webpack-4)| TBD  \n3.x | [master](https://github.com/lependu/fastify-webpack-hmr/tree/master) | [3.x](https://github.com/fastify/fastify/tree/master) | [4.x](https://github.com/webpack/webpack/tree/webpack-4)| TBD  \n\n\u003e :warning: This project is meant to be used in development environment only.  \n\n## Usage\n\nFor a more detailed exampe please check out the `example` directory.  \nThe plugin accepts a configuration object, with a following properties:\n\n### compiler\n`{object}` `optional`\n\nIf you pass a custom `webpack compiler` instance to the plugin, it will pass that to the middlewares.  \n*Note:* if you pass a `compiler` option the plugin omits the `config` option.\n```js\nconst fastify = require('fastify')()\nconst HMR = require('fastify-webpack-hmr')\nconst webpack = require('webpack')\nconst webpackConfig = require('path/to/your/webpack/config')\n\nconst compiler = webpack(webpackConfig)\n\nfastify.register(HMR, { compiler })\n\nfastify.listen(3000)\n```\n\n### config\n`{string|object}` `optional`\n\nIf you pass this option instead of a `compiler`, the plugin tries to set up the webpack compiler and will pass that compiler instance to the middlewares. For the detailed configuration options please check the [`webpack documentation`](https://webpack.js.org/configuration/).  \n\nIf config is a `string` it has to be a path to a valid webpack configuration file.\n```js\nconst fastify = require('fastify')()\nconst HMR = require('fastify-webpack-hmr')\nconst { join } = require('path')\n\nconst config = join(__dirname, 'path.to.your.webpack.config')\n\nfastify.register(HMR, { config })\n\nfastify.listen(3000)\n  ```\n  \nOr you can directly pass a valid webpack configuration `object`.\n```js\nconst fastify = require('fastify')()\nconst HMR = require('fastify-webpack-hmr')\nconst { join } = require('path')\nconst hotConf = 'webpack-hot-middleware/client?path=/__webpack_hmr'\n\nconst config = {\n  mode: 'development', // Prevents webpack warning\n  // Add the webpack-hot-middleware to the entry point array.\n  entry: [join(__dirname, 'path.to.your.client.file'), hotConf],\n  output: {\n    publicPath: '/assets',\n    filename: 'main.js'\n  }\n}\n\nfastify.register(HMR, { config })\n\nfastify.listen(3000)\n```\n\n### webpackDev\n`{object}` `optional`\n\nAdditional configuration options which will be passed to [`webpack-dev-middleware`](https://github.com/webpack/webpack-dev-middleware#options).\n\n### webpackHot\n`{boolean|object}` `optional`\n\nYou can `disable` webpack-hot-middleware if you set this option `false`.\nIf it is an `object` it will be passed to [`webpack-hot-middleware`](https://github.com/webpack-contrib/webpack-hot-middleware#config).\n\n## Multi compiler mode\nIn multi compiler mode you must pass the `webpackDev.publicPath` option to the plugin.\n\n\u003e *Tip:* Don't forget to set name parameter when you register `webpack-hot-middleware` in entry array. It makes sure that bundles don't process each other's updates.\n\n```js\nconst fastify = require('fastify')()\nconst HMR = require('fastify-webpack-hmr')\nconst { join } = require('path')\nconst hotConf = 'webpack-hot-middleware/client?path=/__webpack_hmr'\n\nconst config = [\n  {\n    name: 'mobile',\n    mode: 'development',\n    entry: [\n      join(__dirname, 'example', 'mobile.js'),\n      `${hotConf}\u0026name=mobile`\n    ],\n    stats: false,\n    output: { filename: 'mobile.js', publicPath: '/assets' }\n  },\n  {\n    name: 'desktop',\n    mode: 'development',\n    entry: [\n      join(__dirname, 'example', 'desktop.js'),\n      `${hotConf}\u0026name=desktop`\n    ],\n    stats: false,\n    output: { filename: 'desktop.js', publicPath: '/assets' }\n  }\n]\n\nconst webpackDev = { publicPath: '/assets' }\n\nfastify.register(HMR, { config, webpackDev })\n\nfastify.listen(3000)\n```\n\n## Reference\nThis plugin decorates the `fastify` instance with `webpack` object. The object has the following properties:\n- `compiler` The [`webpack compiler` instance](https://webpack.js.org/api/node/).\n- `dev` The [`webpack-dev-middleware` instance](https://github.com/webpack/webpack-dev-middleware#api).\n- `hot` The [`webpack-hot-middleware` instance](https://github.com/webpack-contrib/webpack-hot-middleware).\n\n## License\nLicensed under [MIT](./LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flependu%2Ffastify-webpack-hmr","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flependu%2Ffastify-webpack-hmr","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flependu%2Ffastify-webpack-hmr/lists"}