diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index a056fb5993..c97bbb32ba 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -1 +1 @@ -* @evilebottnawi @hiroppy +* @evilebottnawi @hiroppy @Loonride diff --git a/CHANGELOG.md b/CHANGELOG.md index 83096aba95..8763a9db92 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,74 @@ All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. +### [3.10.3](https://github.com/webpack/webpack-dev-server/compare/v3.10.2...v3.10.3) (2020-02-05) + + +### Bug Fixes + +* forward error requests to the proxy ([#2425](https://github.com/webpack/webpack-dev-server/issues/2425)) ([e291cd4](https://github.com/webpack/webpack-dev-server/commit/e291cd4922f66c5c69dfd1fd3839812cfa502de5)) + +### [3.10.2](https://github.com/webpack/webpack-dev-server/compare/v3.10.0...v3.10.2) (2020-01-31) + + +### Bug Fixes + +* fallthrough non `GET` and `HEAD` request to routes ([#2374](https://github.com/webpack/webpack-dev-server/issues/2374)) ([ebe8eca](https://github.com/webpack/webpack-dev-server/commit/ebe8eca37957a9009f8627e7dfb82699606846de)) +* add an optional peer dependency on webpack-cli ([#2396](https://github.com/webpack/webpack-dev-server/issues/2396)) ([aa365df](https://github.com/webpack/webpack-dev-server/commit/aa365dfd7e86c5dca31304bd5dcfe9bb9b767b40)) +* add heartbeat for the websocket server ([#2404](https://github.com/webpack/webpack-dev-server/issues/2404)) ([1a7c827](https://github.com/webpack/webpack-dev-server/commit/1a7c8273de5a5b164c63c9919950babd7ecfaadb)) + +### [3.10.1](https://github.com/webpack/webpack-dev-server/compare/v3.10.0...v3.10.1) (2019-12-19) + + +### Bug Fixes + +* ie11 compatibility ([1306abe](https://github.com/webpack/webpack-dev-server/commit/1306abeb8c5fd125952cdc177fdf38c2c31b3c4f)) + +## [3.10.0](https://github.com/webpack/webpack-dev-server/compare/v3.9.0...v3.10.0) (2019-12-18) + + +### Features + +* **client:** allow sock port to use location's port (`sockPort: 'location'`) ([#2341](https://github.com/webpack/webpack-dev-server/issues/2341)) ([dc10d06](https://github.com/webpack/webpack-dev-server/commit/dc10d0647413ad57814b684b5f6ef3659531f0f6)) +* **server:** add `contentBasePublicPath` option ([#2150](https://github.com/webpack/webpack-dev-server/issues/2150)) ([cee700d](https://github.com/webpack/webpack-dev-server/commit/cee700d59aff644a499ee310c4a32d5c5693e559)) + + +### Bug Fixes + +* **client:** don't override protocol for socket connection to 127.0.0.1 ([#2303](https://github.com/webpack/webpack-dev-server/issues/2303)) ([3a31917](https://github.com/webpack/webpack-dev-server/commit/3a31917a02818dabb3dc549e3e4994618475d131)), closes [#2302](https://github.com/webpack/webpack-dev-server/issues/2302) +* **server:** respect sockPath on transportMode: 'ws' ([#2310](https://github.com/webpack/webpack-dev-server/issues/2310)) ([#2311](https://github.com/webpack/webpack-dev-server/issues/2311)) ([e188542](https://github.com/webpack/webpack-dev-server/commit/e188542d888dbb55be64c9da2f747343b73c319f)) +* https on chrome linux ([#2330](https://github.com/webpack/webpack-dev-server/issues/2330)) ([dc8b475](https://github.com/webpack/webpack-dev-server/commit/dc8b47510e24649edb38e5a07579be389898189e)) +* support webpack@5 ([#2359](https://github.com/webpack/webpack-dev-server/issues/2359)) ([8f89c01](https://github.com/webpack/webpack-dev-server/commit/8f89c0188579a419dc68021f8bc0fbeae70cbe5d)) + +## [3.9.0](https://github.com/webpack/webpack-dev-server/compare/v3.8.2...v3.9.0) (2019-10-22) + + +### Bug Fixes + +* add `hostname` and `port` to bonjour name to prevent name collisions ([#2276](https://github.com/webpack/webpack-dev-server/issues/2276)) ([d8af2d9](https://github.com/webpack/webpack-dev-server/commit/d8af2d9)) +* add `extKeyUsage` to self-signed cert ([#2274](https://github.com/webpack/webpack-dev-server/issues/2274)) ([a4dbc3b](https://github.com/webpack/webpack-dev-server/commit/a4dbc3b)) + + +### Features + +* add multiple `openPage` support ([#2266](https://github.com/webpack/webpack-dev-server/issues/2266)) ([c9e9178](https://github.com/webpack/webpack-dev-server/commit/c9e9178)) + +### [3.8.2](https://github.com/webpack/webpack-dev-server/compare/v3.8.1...v3.8.2) (2019-10-02) + +### Security + +* update `selfsigned` package + +### [3.8.1](https://github.com/webpack/webpack-dev-server/compare/v3.8.0...v3.8.1) (2019-09-16) + + +### Bug Fixes + +* add null check for connection.headers ([#2200](https://github.com/webpack/webpack-dev-server/issues/2200)) ([7964997](https://github.com/webpack/webpack-dev-server/commit/7964997)) +* false positive for an absolute path in the `ContentBase` option on windows ([#2202](https://github.com/webpack/webpack-dev-server/issues/2202)) ([68ecf78](https://github.com/webpack/webpack-dev-server/commit/68ecf78)) +* add status in quiet log level ([#2235](https://github.com/webpack/webpack-dev-server/issues/2235)) ([7e2224e](https://github.com/webpack/webpack-dev-server/commit/7e2224e)) +* scriptHost in client ([#2246](https://github.com/webpack/webpack-dev-server/issues/2246)) ([00903f6](https://github.com/webpack/webpack-dev-server/commit/00903f6)) + ## [3.8.0](https://github.com/webpack/webpack-dev-server/compare/v3.7.2...v3.8.0) (2019-08-09) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 8977de369e..b2f609847b 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -2,10 +2,13 @@ trigger: - master - next +variables: + npm_config_cache: $(Pipeline.Workspace)/.npm + jobs: - job: Lint pool: - vmImage: ubuntu-16.04 + vmImage: ubuntu-latest steps: - task: NodeTool@0 inputs: @@ -20,10 +23,12 @@ jobs: node -v npm -v displayName: 'Print versions' - - task: Npm@1 + - task: CacheBeta@1 inputs: - command: custom - customCommand: ci + key: npm | $(Agent.OS) | package-lock.json + path: $(npm_config_cache) + displayName: 'Cache npm' + - script: npm ci displayName: 'Install dependencies' - script: npm run lint displayName: 'Run lint' @@ -34,10 +39,13 @@ jobs: - job: Linux pool: - vmImage: ubuntu-16.04 + vmImage: ubuntu-latest strategy: - maxParallel: 5 + maxParallel: 6 matrix: + node-13: + node_version: ^13.0.0 + webpack_version: latest node-12: node_version: ^12.0.0 webpack_version: latest @@ -50,6 +58,9 @@ jobs: node-6: node_version: ^6.9.0 webpack_version: latest + node-10-canary: + node_version: ^10.13.0 + webpack_version: next steps: - task: NodeTool@0 inputs: @@ -64,10 +75,12 @@ jobs: node -v npm -v displayName: 'Print versions' - - task: Npm@1 + - task: CacheBeta@1 inputs: - command: custom - customCommand: ci + key: npm | $(Agent.OS) | package-lock.json + path: $(npm_config_cache) + displayName: 'Cache npm' + - script: npm ci displayName: 'Install dependencies' - script: npm i webpack@$(webpack_version) displayName: 'Install "webpack@$(webpack_version)"' @@ -85,10 +98,13 @@ jobs: - job: macOS pool: - vmImage: macOS-10.14 + vmImage: macOS-latest strategy: - maxParallel: 5 + maxParallel: 6 matrix: + node-13: + node_version: ^13.0.0 + webpack_version: latest node-12: node_version: ^12.0.0 webpack_version: latest @@ -101,6 +117,9 @@ jobs: node-6: node_version: ^6.9.0 webpack_version: latest + node-10-canary: + node_version: ^10.13.0 + webpack_version: next steps: - task: NodeTool@0 inputs: @@ -115,10 +134,12 @@ jobs: node -v npm -v displayName: 'Print versions' - - task: Npm@1 + - task: CacheBeta@1 inputs: - command: custom - customCommand: ci + key: npm | $(Agent.OS) | package-lock.json + path: $(npm_config_cache) + displayName: 'Cache npm' + - script: npm ci displayName: 'Install dependencies' - script: npm i webpack@$(webpack_version) displayName: 'Install "webpack@$(webpack_version)"' @@ -136,10 +157,13 @@ jobs: - job: Windows pool: - vmImage: windows-2019 + vmImage: windows-latest strategy: - maxParallel: 5 + maxParallel: 6 matrix: + node-13: + node_version: ^13.0.0 + webpack_version: latest node-12: node_version: ^12.0.0 webpack_version: latest @@ -152,6 +176,9 @@ jobs: node-6: node_version: ^6.9.0 webpack_version: latest + node-10-canary: + node_version: ^10.13.0 + webpack_version: next steps: - script: 'git config --global core.autocrlf input' displayName: 'Config git core.autocrlf' @@ -169,10 +196,12 @@ jobs: node -v npm -v displayName: 'Print versions' - - task: Npm@1 + - task: CacheBeta@1 inputs: - command: custom - customCommand: ci + key: npm | $(Agent.OS) | package-lock.json + path: $(npm_config_cache) + displayName: 'Cache npm' + - script: npm ci displayName: 'Install dependencies' - script: npm i webpack@$(webpack_version) displayName: 'Install "webpack@$(webpack_version)"' diff --git a/bin/cli-flags.js b/bin/cli-flags.js new file mode 100644 index 0000000000..973cee7ae0 --- /dev/null +++ b/bin/cli-flags.js @@ -0,0 +1,195 @@ +'use strict'; + +const ADVANCED_GROUP = 'Advanced options:'; +const DISPLAY_GROUP = 'Stats options:'; +const SSL_GROUP = 'SSL options:'; +const CONNECTION_GROUP = 'Connection options:'; +const RESPONSE_GROUP = 'Response options:'; +const BASIC_GROUP = 'Basic options:'; + +module.exports = { + devServer: [ + { + name: 'bonjour', + type: Boolean, + describe: 'Broadcasts the server via ZeroConf networking on start', + }, + { + name: 'lazy', + type: Boolean, + describe: 'Lazy', + }, + { + name: 'liveReload', + type: Boolean, + defaultValue: true, + describe: 'Enables/Disables live reloading on changing files', + }, + { + name: 'serveIndex', + type: Boolean, + describe: 'Enables/Disables serveIndex middleware', + defaultValue: true, + }, + { + name: 'inline', + type: Boolean, + defaultValue: true, + describe: + 'Inline mode (set to false to disable including client scripts like livereload)', + }, + { + name: 'profile', + type: Boolean, + describe: 'Print compilation profile data for progress steps', + }, + { + name: 'progress', + type: Boolean, + describe: 'Print compilation progress in percentage', + group: BASIC_GROUP, + }, + { + name: 'hot-only', + type: Boolean, + describe: 'Do not refresh page if HMR fails', + group: ADVANCED_GROUP, + }, + { + name: 'stdin', + type: Boolean, + describe: 'close when stdin ends', + }, + { + name: 'open', + type: String, + describe: + 'Open the default browser, or optionally specify a browser name', + }, + { + name: 'useLocalIp', + type: Boolean, + describe: 'Open default browser with local IP', + }, + { + name: 'open-page', + type: String, + describe: 'Open default browser with the specified page', + }, + { + name: 'client-log-level', + type: String, + group: DISPLAY_GROUP, + defaultValue: 'info', + describe: + 'Log level in the browser (trace, debug, info, warn, error or silent)', + }, + { + name: 'https', + type: Boolean, + group: SSL_GROUP, + describe: 'HTTPS', + }, + { + name: 'http2', + type: Boolean, + group: SSL_GROUP, + describe: 'HTTP/2, must be used with HTTPS', + }, + { + name: 'key', + type: String, + describe: 'Path to a SSL key.', + group: SSL_GROUP, + }, + { + name: 'cert', + type: String, + describe: 'Path to a SSL certificate.', + group: SSL_GROUP, + }, + { + name: 'cacert', + type: String, + describe: 'Path to a SSL CA certificate.', + group: SSL_GROUP, + }, + { + name: 'pfx', + type: String, + describe: 'Path to a SSL pfx file.', + group: SSL_GROUP, + }, + { + name: 'pfx-passphrase', + type: String, + describe: 'Passphrase for pfx file.', + group: SSL_GROUP, + }, + { + name: 'content-base', + type: String, + describe: 'A directory or URL to serve HTML content from.', + group: RESPONSE_GROUP, + }, + { + name: 'watch-content-base', + type: Boolean, + describe: 'Enable live-reloading of the content-base.', + group: RESPONSE_GROUP, + }, + { + name: 'history-api-fallback', + type: Boolean, + describe: 'Fallback to /index.html for Single Page Applications.', + group: RESPONSE_GROUP, + }, + { + name: 'compress', + type: Boolean, + describe: 'Enable gzip compression', + group: RESPONSE_GROUP, + }, + // findPort is currently not set up + { + name: 'port', + type: Number, + describe: 'The port', + group: CONNECTION_GROUP, + }, + { + name: 'disable-host-check', + type: Boolean, + describe: 'Will not check the host', + group: CONNECTION_GROUP, + }, + { + name: 'socket', + type: String, + describe: 'Socket to listen', + group: CONNECTION_GROUP, + }, + { + name: 'public', + type: String, + describe: 'The public hostname/ip address of the server', + group: CONNECTION_GROUP, + }, + { + name: 'host', + type: String, + describe: 'The hostname/ip address the server will bind to', + group: CONNECTION_GROUP, + }, + // use command-line-args "multiple" option, allowing the usage: --allowed-hosts host1 host2 host3 + // instead of the old, comma-separated syntax: --allowed-hosts host1,host2,host3 + { + name: 'allowed-hosts', + type: String, + describe: + 'A list of hosts that are allowed to access the dev server, separated by spaces', + group: CONNECTION_GROUP, + multiple: true, + }, + ], +}; diff --git a/client-src/default/utils/createSocketUrl.js b/client-src/default/utils/createSocketUrl.js index d847769021..4f5ebdd592 100644 --- a/client-src/default/utils/createSocketUrl.js +++ b/client-src/default/utils/createSocketUrl.js @@ -3,43 +3,60 @@ /* global self */ const url = require('url'); -const querystring = require('querystring'); const getCurrentScriptSource = require('./getCurrentScriptSource'); -function createSocketUrl(resourceQuery) { +function createSocketUrl(resourceQuery, currentLocation) { let urlParts; if (typeof resourceQuery === 'string' && resourceQuery !== '') { // If this bundle is inlined, use the resource query to get the correct url. - urlParts = url.parse(resourceQuery.substr(1)); + // format is like `?http://0.0.0.0:8096&sockPort=8097&sockHost=localhost` + urlParts = url.parse( + resourceQuery + // strip leading `?` from query string to get a valid URL + .substr(1) + // replace first `&` with `?` to have a valid query string + .replace('&', '?'), + true + ); } else { // Else, get the url from the