{"_id":"@_pearofducks/webpack-plugin-serve","_rev":"1-d94a7a58d258543f7f451022ec1e479f","name":"@_pearofducks/webpack-plugin-serve","dist-tags":{"latest":"0.3.1"},"versions":{"0.3.1":{"name":"@_pearofducks/webpack-plugin-serve","version":"0.3.1","description":"A Development Server in a Webpack Plugin","license":"MPL-2.0","repository":{"type":"git","url":"git+https://github.com/shellscape/webpack-plugin-serve.git"},"author":{"name":"shellscape"},"homepage":"https://github.com/shellscape/webpack-plugin-serve","bugs":{"url":"https://github.com/shellscape/webpack-plugin-serve/issues"},"bin":"","main":"lib/index.js","typings":"index.d.ts","engines":{"node":">= 8.0.0 < 9.0.0 || >= 10.0.0 < 10.14.0 || >= 11.0.0"},"scripts":{"ci:coverage":"nyc npm run test && nyc report --reporter=text-lcov > coverage.lcov","ci:lint":"npm run lint && npm run security","ci:lint:commits":"commitlint --from=${CIRCLE_BRANCH} --to=${CIRCLE_SHA1}","ci:test":"npm run test -- --verbose","commitlint":"commitlint","commitmsg":"commitlint -e $GIT_PARAMS","dev":"npm run dev:clean && node node_modules/webpack-nano/bin/wp --config test/fixtures/simple/webpack.config.js","dev:clean":"del test/fixtures/multi/output/* test/fixtures/simple/output/*","dev:multi":"npm run dev:clean && node node_modules/webpack-nano/bin/wp --config test/fixtures/multi/webpack.config.js","faq:toc":"echo 'temporarily disabled' # markdown-toc -i .github/FAQ.md","lint":"eslint --fix --cache lib test","lint-staged":"lint-staged","security":"npm audit","test":"ava"},"peerDependencies":{"webpack":"^4.20.2"},"dependencies":{"chalk":"^2.4.1","connect-history-api-fallback":"^1.5.0","http-proxy-middleware":"^0.19.0","is-promise":"^2.1.0","joi":"^14.3.0","koa":"^2.5.3","koa-compress":"^3.0.0","koa-connect":"^2.0.1","koa-route":"^3.2.0","koa-static":"^5.0.0","loglevelnext":"^3.0.0","nanoid":"^2.0.0","onetime":"^2.0.1","opn":"^5.4.0","p-defer":"^1.0.0","strip-ansi":"^5.0.0","ws":"^6.0.0"},"devDependencies":{"@commitlint/cli":"^7.1.2","@commitlint/config-conventional":"^7.1.2","ava":"^1.0.1","cpy":"^7.0.1","del":"^3.0.0","del-cli":"^1.1.0","eslint":"^5.6.1","eslint-config-shellscape":"^2.0.2","execa":"^1.0.0","get-port":"^4.0.0","lint-staged":"^8.1.0","make-dir":"^1.3.0","node-fetch":"^2.2.0","nyc":"^13.0.1","pre-commit":"^1.2.2","prettier":"^1.14.3","puppeteer":"^1.11.0","standard-version":"^4.4.0","webpack":"^4.28.1","webpack-nano":"^0.5.1"},"keywords":["dev","development","devserver","serve","server","webpack"],"pre-commit":"lint-staged","lint-staged":{"*.js":["eslint --fix","git add"]},"nyc":{"include":["lib/*.js"],"exclude":["lib/client*.js","test/"]},"gitHead":"8e02e8248be90e6ec1e89e6177d26537d14f7385","_id":"@_pearofducks/webpack-plugin-serve@0.3.1","_npmVersion":"6.5.0","_nodeVersion":"11.4.0","_npmUser":{"name":"pearofducks","email":"pearofducks+npm@gmail.com"},"dist":{"integrity":"sha512-C2IZ6az/AO/U8f77ddCTLEaze5oAnd6/9gFh2AWUqYl4F3OZ9MBZyib1jZrGeVWh9nrFxnIy3R2Mx9cdHuqTUg==","shasum":"9b764daceb78fd9a7f511276173f74e700655aa4","tarball":"https://registry.npmjs.org/@_pearofducks/webpack-plugin-serve/-/webpack-plugin-serve-0.3.1.tgz","fileCount":22,"unpackedSize":78278,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJcMP5tCRA9TVsSAnZWagAAMtkQAJx4htqC8YUDiwCd7+K2\n/ny2n9U18iuaV8Cde65xVjKDTM2VwaMgIW6XVFjUeDZCNyLHebJggwJaUMdI\nQr9IsQ2ZDZovzAXCbO2f0BEVKXsHqtzgQrGoQSX0hj70oo5hw+3oPiQ53FQR\n18sU4uTUosG39A5wl78l6FNERIiRy2M85D5w6tUN0GNo2N4iJOkHb9pM30Nv\nI0/kBM9ySbx7YxpASGmYL1P2sp/jK6PqSjaiUPJyyrMYygaeI9Xe0rDKp0U5\nvIAN7m6WAI0aP0Dj7W8DpHsSWwfqt1RcwaT3rfrKAG66uUT+SkfL0niVZBgr\nTTFPRUpSP1BWplhxp1PAj/qGmWeAHiEu7F2HsynkYjwY80kL1vdtRAh2CvAa\nhLnt3MYv4BxzkGwp+Xf+RpHYyywPVSh1KxBeoREFj+Pl56Qrg7reN2zF7Fvy\nsFvwUMihrniSJ6+vsGfGyihp4EUmWnR6tv06rTiOUGI5fw/AFiz46TiN88MV\nguYcjeSDDVyczx8WPFH4Ckyy0GGP4/sLjxyQ/Sf1UdiFizoL7Ny0yREXqT87\nmuokgfWU+cCX+9p6sZx+1BUPG9HVXkg3N+u7b583MERYsAyE84JJezhjbifN\ne7dBAOSFum1MdpBO26T+/Vn9ehPyFVco6qUpgFLXxhiCWlr/id6uC9gNphv3\nJ/iS\r\n=8b0I\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCID2t/WmVC70bErYjYQ719+RTRVhycCmfIha+mx7dnM/gAiAK4kKyrElXGOfocYW2hz100Mh8owsEvA5tUqNKx+Oblg=="}]},"maintainers":[{"name":"pearofducks","email":"pearofducks+npm@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/webpack-plugin-serve_0.3.1_1546714732814_0.6349135981092666"},"_hasShrinkwrap":false}},"time":{"created":"2019-01-05T18:58:52.633Z","0.3.1":"2019-01-05T18:58:52.941Z","modified":"2022-04-04T10:51:40.818Z"},"maintainers":[{"name":"pearofducks","email":"pearofducks+npm@gmail.com"}],"description":"A Development Server in a Webpack Plugin","homepage":"https://github.com/shellscape/webpack-plugin-serve","keywords":["dev","development","devserver","serve","server","webpack"],"repository":{"type":"git","url":"git+https://github.com/shellscape/webpack-plugin-serve.git"},"author":{"name":"shellscape"},"bugs":{"url":"https://github.com/shellscape/webpack-plugin-serve/issues"},"license":"MPL-2.0","readme":"[tests]: \thttps://img.shields.io/circleci/project/github/shellscape/webpack-plugin-serve.svg\n[tests-url]: https://circleci.com/gh/shellscape/webpack-plugin-serve\n\n[cover]: https://codecov.io/gh/shellscape/webpack-plugin-serve/branch/master/graph/badge.svg\n[cover-url]: https://codecov.io/gh/shellscape/webpack-plugin-serve\n\n[size]: https://packagephobia.now.sh/badge?p=webpack-plugin-serve\n[size-url]: https://packagephobia.now.sh/result?p=webpack-plugin-serve\n\n[https]: https://nodejs.org/api/https.html#https_https_createserver_options_requestlistener\n[http2]: https://nodejs.org/api/http2.html#http2_http2_createserver_options_onrequesthandler\n[http2tls]: https://nodejs.org/api/http2.html#http2_http2_createsecureserver_options_onrequesthandler\n\n<div align=\"center\">\n\t<img width=\"256\" src=\"https://raw.githubusercontent.com/shellscape/webpack-plugin-serve/master/assets/serve.svg?sanitize=true\" alt=\"webpack-plugin-serve\"><br/><br/>\n</div>\n\n[![tests][tests]][tests-url]\n[![cover][cover]][cover-url]\n[![size][size]][size-url]\n\n# webpack-plugin-serve\n\nA Webpack development server in a plugin.\n\nBe sure to [browse our recipes](./recipes/README.md) and peruse the [FAQ](./.github/FAQ.md) after reading the documentation below.\n\n<a href=\"https://www.patreon.com/shellscape\">\n  <img src=\"https://c5.patreon.com/external/logo/become_a_patron_button@2x.png\" width=\"160\">\n</a>\n\n_Please consider donating if you find this project useful._\n\n## Requirements\n\n`webpack-plugin-serve` is an [evergreen 🌲](./.github/FAQ.md#what-does-evergreen-mean) module.\n\nThis module requires an [Active LTS](https://github.com/nodejs/Release) Node version (v8.0.0+ or v10.0.0+). The client scripts in this module require [browsers which support `async/await`](https://caniuse.com/#feat=async-functions). Users may also choose to compile the client script via an appropriately configured [Babel](https://babeljs.io/) webpack loader for use in older browsers.\n\n## Feature Parity\n\nIn many ways, `webpack-plugin-serve` stands out from the alternatives. Feature parity with existing solutions is a high priority. If a feature you've come to expect in an alternative isn't directly available, it's likely easy to implement via middleware. Feel free to open an issue for direction.\n\nFor those interested in direct comparisons, please see the [Feature Grid](./.github/FEATURES.md) for a breakdown of feature comparisons between `webpack-plugin-serve` and the alternatives.\n\n## Install\n\nUsing npm:\n\n```console\nnpm install webpack-nano webpack-plugin-serve --save-dev\n```\n\n_Note: We recommend using [webpack-nano](https://github.com/shellscape/webpack-nano), a very tiny, very clean webpack CLI._\n\n## Usage\n\nCreate a `webpack.config.js` file:\n\n```js\nconst { WebpackPluginServe: Serve } = require('webpack-plugin-serve');\nconst options = { ... };\n\nmodule.exports = {\n\t// an example entry definition\n\tentry: [\n\t\t'app.js',\n\t\t'webpack-plugin-serve/client' // ← important: this is required, where the magic happens in the browser\n\t]\n  ...\n  plugins: [\n    new Serve(options)\n  ],\n  watch: true  // ← important: webpack and the server will continue to run in watch mode\n};\n\n```\n\nAnd run `webpack`:\n\n```console\n$ npx wp\n```\n\n## Options\n\n### `client`\nType: `Object`<br>\nDefault: `null`\n\nSets options specifically for the client script. In most situations this option doesn't need to be modified.\n\n#### Properties\n\n#### `client.address`\nType: `String`\n\nIf set, allows for overriding the `WebSocket` address, which corresponds to the server address by default. Values for this option should be in a valid `{host}:{port}` format. e.g. `localhost:433`.\n\n#### `client.retry`\nType: `Boolean`\n\nIf `true`, instructs the client to attempt to reconnect all `WebSockets` when their connects are interrupted, usually as a result of the server being stopped and/or restarted. _Note: This can be very spammy in the browser console, as there is no way to suppress error messages from the browser when a `WebSocket` fails to connect._\n\n### `compress`\nType: `Boolean`<br>\nDefault: `false`\n\nIf `true`, enables compression middleware which serves files with GZip compression.\n\n### `historyFallback`\nType: `Boolean | Object`<br>\nDefault: `false`\n\nIf `true`, enables History API Fallback via [`connect-history-api-fallback`](https://github.com/bripkens/connect-history-api-fallback). Users may also pass an `options` Object to this property. Please see `connect-history-api-fallback` for details.\n\nThis setting can be handy when using the HTML5 History API; `index.html` page will likely have to be served in place of any 404 responses from the server, specially when developing Single Page Applications.\n\n### `hmr`\nType: `boolean`<br>\nDefault: `true`\n\nIf `true`, will enable [`Hot Module Replacement`](https://webpack.js.org/concepts/hot-module-replacement/) which exchanges, adds, or removes modules from a bundle dynamically while the application still running, without the need of a full page reload.\n\n### `host`\nType: `String | Promise`<br>\nDefault: `::` for IPv6, `127.0.0.1` for IPv4\n\nSets the host the server should listen from. Users may choose to set this to a `Promise`, or a `Function` which returns a `Promise` for situations in which the server needs to wait for a host to resolve.\n\n_Note: The default URI is `http://[::]:{port}`. For more info, please read [the FAQ](.github/FAQ.md)._\n\n### `http2`\nType: `boolean` | [`http2` options](https://nodejs.org/api/http2.html#http2_http2_createserver_options_onrequesthandler) | [secure `http2` options](https://nodejs.org/api/http2.html#http2_http2_createsecureserver_options_onrequesthandler)\n\nIf set, this option will instruct the server to enable HTTP2. Properties for this option should correspond to [HTTP2 options][http2] or [HTTP2 SSL options][http2tls].\n\n### `https`\nType: `Object`<br>\nDefault: `null`\n\nIf set, this option will instruct the server to enable SSL via HTTPS. Properties for this option should correspond to [HTTPS options][https].\n\n### `liveReload`\nType: `boolean`<br>\nDefault: `false`\n\nIf `true`, will instruct the client to perform a full page reload after each build.\n\n_Note: This option overrides any value set for the `hmr` option property._\n\n### `log`\nType: `String`<br>\nDefault: `{ level: 'info' }`<br>\nValid `level` Values: `'trace' | 'debug' | 'info' | 'warn' | 'error'`\n\nSets a level for which messages should appear in the console. For example: if `warn` is set, every message at the `warn` and `error` levels will be visible. This module doesn't produce much log output, so you probably won't have to fiddle with this.\n\nA `timestamp: true` property/value may also be used to preface each log line with an `HH:mm:ss` format timestamp.\n\n### `middleware`\nType: `Function`<br>\nDefault: `(app, builtins) => {}`\n\nAllows users to implement custom middleware, and manipulate the order in which built-in middleware is executed. This method may also return a `Promise` to pause further middleware evaluation until the `Promise` resolves. This property should only be set by users with solid knowledge of Express/Koa style middleware and those which understand the consequences of manipulating the order of built-in middleware.\n\n#### Example\n\n```js\n// webpack.config.js\nmodule.exports = {\n  plugins: [\n    new WebpackPluginServe({\n      middleware: (app, builtins) =>\n        app.use(async (ctx, next) => {\n          ctx.body = 'Hello world';\n          await next();\n        })\n    })\n  ]\n};\n```\n\nCurrently supported built-in middleware that are available on the `builtins` parameter:\n\n`compress` → forwards to [koa-compress](https://github.com/koajs/compress)<br>\n`four0four` → handles requests that result in a 404 status<br>\n`historyFallback` → forwards to [connect-history-api-fallback](https://github.com/bripkens/connect-history-api-fallback/)<br>\n`proxy` → forwards to [http-proxy-middleware](https://github.com/chimurai/http-proxy-middleware)<br/>\n`static` → forwards to [koa-static](https://github.com/koajs/static)<br>\n`websocket` → Custom middleware that provides `WebSocket` support\n\n### `open`\nType: `boolean | Object`<br>\nDefault: `false`\n\nIf `true`, opens the default browser to the set `host` and `port`. Users may also choose to pass an `Object` containing options for the [`opn`](https://github.com/sindresorhus/opn) module, which is used for this feature.\n\n### `port`\nType: `Number | Promise`<br>\nDefault: `55555`\n\nSets the port on which the server should listen. Users may choose to set this to a `Promise`, or a `Function` which returns a `Promise` for situations in which the server needs to wait for a port to resolve.\n\n### `progress`\nType: `boolean | String`<br>\nDefault: `true`\n\nIf [truthy](https://developer.mozilla.org/en-US/docs/Glossary/Truthy), the module will add a `ProgressPlugin` instance to the `webpack` compiler, and display a progress indicator on the page within the browser.\n\nIf a value of `'minimal'` is set, the progress indicator will render as a small, colored bar at the top of the window. This can be useful when the default fancy progress indicator interferes with elements in the page.\n\n### `static`\nType: `String | Array(String)`<br>\nDefault: `compiler.context`\n\nSets the directory(s) from which static files will be served. Bundles will be served from the `output` config setting.\n\n### `status`\nType: `boolean`<br>\nDefault: `true`\n\nBy default, `webpack-plugin-serve` will display a status overlay when a build results in errors and/or warnings. To disable this feature, set `status: false` in the options.\n\n<div align=\"center\">\n\t<img height=\"244\" src=\"assets/status-overlay.png\" alt=\"status overlay\"><br/><br/>\n</div>\n\nWhen the minimize button (yellow dot) is clicked, the overlay will shrink to a single small box in the lower right corner of the page and display a status beacon using the same green, red, and yellow colors for build success, errors, and warnings, respectively.\n\n<div align=\"center\">\n\t<img src=\"assets/status-beacons.gif\" alt=\"status beacons\"><br/><br/>\n</div>\n\n## Proxying\n\nProxying with `webpack-plugin-serve` is supported via the [`middleware`](#middleware) option. But while this plugin module doesn't contain any fancy options processing for proxying, it does include access to the [http-proxy-middleware](https://github.com/chimurai/http-proxy-middleware) module by default, and the rest should look familiar to users of `http-proxy-middleware`.\n\n```js\n// webpack.config.js\nmodule.exports = {\n  ...,\n  plugins: [\n    new WebpackPluginServe({\n      middleware: (app, builtins) => {\n        app.use(builtins.proxy('/api', { target: 'http://10.10.10.1:1337' }));\n      }\n    })\n  ]\n};\n```\n\n_Note: The `app.use(...)` call here is slightly different than what Express users are used to seeing with `http-proxy-middleware`. This is due to subtle differences in how the module interacts with `Koa`, which is used under the hood in this plugin._\n\n## Meta\n\n[CONTRIBUTING](./.github/CONTRIBUTING.md)\n\n[LICENSE (Mozilla Public License)](./LICENSE)\n","readmeFilename":"README.md"}