Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

README.md 5.3 KiB

3 år sedan
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. <div align="center">
  2. <a href="https://github.com/webpack/webpack">
  3. <img width="200" height="200" src="https://webpack.js.org/assets/icon-square-big.svg">
  4. </a>
  5. </div>
  6. [![npm][npm]][npm-url]
  7. [![node][node]][node-url]
  8. [![deps][deps]][deps-url]
  9. [![tests][tests]][tests-url]
  10. [![coverage][cover]][cover-url]
  11. [![chat][chat]][chat-url]
  12. # webpack-dev-server
  13. Use [webpack](https://webpack.js.org) with a development server that provides
  14. live reloading. This should be used for **development only**.
  15. It uses [webpack-dev-middleware][middleware-url] under the hood, which provides
  16. fast in-memory access to the webpack assets.
  17. ## Getting Started
  18. First things first, install the module:
  19. ```console
  20. npm install webpack-dev-server --save-dev
  21. ```
  22. _Note: While you can install and run webpack-dev-server globally, we recommend
  23. installing it locally. webpack-dev-server will always use a local installation
  24. over a global one._
  25. ## Usage
  26. There are two main, recommended methods of using the module:
  27. ### With the CLI
  28. The easiest way to use it is with the CLI. In the directory where your
  29. `webpack.config.js` is, run:
  30. ```console
  31. node_modules/.bin/webpack-dev-server
  32. ```
  33. ### With NPM Scripts
  34. NPM package.json scripts are a convenient and useful means to run locally installed
  35. binaries without having to be concerned about their full paths. Simply define a
  36. script as such:
  37. ```json
  38. "scripts": {
  39. "start:dev": "webpack-dev-server"
  40. }
  41. ```
  42. And run the following in your terminal/console:
  43. ```console
  44. npm run start:dev
  45. ```
  46. NPM will automagically reference the binary in `node_modules` for you, and
  47. execute the file or command.
  48. ### The Result
  49. Either method will start a server instance and begin listening for connections
  50. from `localhost` on port `8080`.
  51. webpack-dev-server is configured by default to support live-reload of files as
  52. you edit your assets while the server is running.
  53. See [**the documentation**][docs-url] for more use cases and options.
  54. ## Browser Support
  55. While `webpack-dev-server` transpiles the client (browser) scripts to an ES5
  56. state, the project only officially supports the _last two versions of major
  57. browsers_. We simply don't have the resources to support every whacky
  58. browser out there.
  59. If you find an bug with an obscure / old browser, we would actively welcome a
  60. Pull Request to resolve the bug.
  61. ## Support
  62. We do our best to keep Issues in the repository focused on bugs, features, and
  63. needed modifications to the code for the module. Because of that, we ask users
  64. with general support, "how-to", or "why isn't this working" questions to try one
  65. of the other support channels that are available.
  66. Your first-stop-shop for support for webpack-dev-server should by the excellent
  67. [documentation][docs-url] for the module. If you see an opportunity for improvement
  68. of those docs, please head over to the [webpack.js.org repo][wjo-url] and open a
  69. pull request.
  70. From there, we encourage users to visit the [webpack Gitter chat][chat-url] and
  71. talk to the fine folks there. If your quest for answers comes up dry in chat,
  72. head over to [StackOverflow][stack-url] and do a quick search or open a new
  73. question. Remember; It's always much easier to answer questions that include your
  74. `webpack.config.js` and relevant files!
  75. If you're twitter-savvy you can tweet [#webpack][hash-url] with your question
  76. and someone should be able to reach out and lend a hand.
  77. If you have discovered a :bug:, have a feature suggestion, or would like to see
  78. a modification, please feel free to create an issue on Github. _Note: The issue
  79. template isn't optional, so please be sure not to remove it, and please fill it
  80. out completely._
  81. ## Contributing
  82. We welcome your contributions! Please have a read of [CONTRIBUTING.md](CONTRIBUTING.md) for more information on how to get involved.
  83. ## Maintainers
  84. <table>
  85. <tbody>
  86. <tr>
  87. <td align="center">
  88. <img src="https://avatars.githubusercontent.com/SpaceK33z?v=4&s=150">
  89. <br />
  90. <a href="https://github.com/SpaceK33z">Kees Kluskens</a>
  91. </td>
  92. <td align="center">
  93. <img src="https://i.imgur.com/4v6pgxh.png">
  94. <br />
  95. <a href="https://github.com/shellscape">Andrew Powell</a>
  96. </td>
  97. </tr>
  98. </tbody>
  99. </table>
  100. ## Attribution
  101. This project is heavily inspired by [peerigon/nof5](https://github.com/peerigon/nof5).
  102. ## License
  103. #### [MIT](./LICENSE)
  104. [npm]: https://img.shields.io/npm/v/webpack-dev-server.svg
  105. [npm-url]: https://npmjs.com/package/webpack-dev-server
  106. [node]: https://img.shields.io/node/v/webpack-dev-server.svg
  107. [node-url]: https://nodejs.org
  108. [deps]: https://david-dm.org/webpack/webpack-dev-server.svg
  109. [deps-url]: https://david-dm.org/webpack/webpack-dev-server
  110. [tests]: http://img.shields.io/travis/webpack/webpack-dev-server.svg
  111. [tests-url]: https://travis-ci.org/webpack/webpack-dev-server
  112. [cover]: https://codecov.io/gh/webpack/webpack-dev-server/branch/master/graph/badge.svg
  113. [cover-url]: https://codecov.io/gh/webpack/webpack-dev-server
  114. [chat]: https://badges.gitter.im/webpack/webpack.svg
  115. [chat-url]: https://gitter.im/webpack/webpack
  116. [docs-url]: https://webpack.js.org/configuration/dev-server/#devserver
  117. [hash-url]: https://twitter.com/search?q=webpack
  118. [middleware-url]: https://github.com/webpack/webpack-dev-middleware
  119. [stack-url]: https://stackoverflow.com/questions/tagged/webpack-dev-server
  120. [uglify-url]: https://github.com/webpack-contrib/uglifyjs-webpack-plugin
  121. [wjo-url]: https://github.com/webpack/webpack.js.org