-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add sockPath
option (options.sockPath
)
#1553
Changes from 7 commits
01054e8
27fb6a5
4bbc1f6
e6ab166
d52103b
4a07096
4078156
745908f
c0faeeb
bd31f5a
e1d41e0
b2ef4de
1327568
bf67dd6
8332f4f
a3d320e
f384993
7542c35
d252f19
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
|
||
/* global __resourceQuery WorkerGlobalScope self */ | ||
/* eslint prefer-destructuring: off */ | ||
|
||
const querystring = require('querystring'); | ||
const url = require('url'); | ||
const stripAnsi = require('strip-ansi'); | ||
const log = require('loglevel').getLogger('webpack-dev-server'); | ||
|
@@ -196,7 +196,7 @@ const socketUrl = url.format({ | |
auth: urlParts.auth, | ||
hostname, | ||
port: urlParts.port, | ||
pathname: urlParts.path == null || urlParts.path === '/' ? '/sockjs-node' : urlParts.path | ||
pathname: urlParts.path == null || urlParts.path === '/' ? '/sockjs-node' : (querystring.parse(urlParts.path).sockPath || urlParts.path) | ||
alexander-akait marked this conversation as resolved.
Show resolved
Hide resolved
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why we need use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That I don't know the answer to. It was left over from the initial pr and I kinda just assumed was how stuff was done. Will investigate and come back with an answer. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @trescenzi thanks! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So what's happening here is that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @trescenzi just add this comment to code 👍 |
||
}); | ||
|
||
socket(socketUrl, onSocketMsg); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# Node.js API - Simple | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please remove all |
||
|
||
```shell | ||
node server.js | ||
``` | ||
|
||
Starts a simple webpack-dev-server setup via the Node API. Open `http://localhost:8080/` to go the app. | ||
|
||
## What should happen | ||
|
||
In the app you should see "It's working." | ||
|
||
In `app.js`, uncomment the code that results in an error and save. This error should be visible in the CLI and devtools. | ||
|
||
Then, in `app.js`, uncomment the code that results in a warning. This warning should be visible in the CLI and devtools. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
'use strict'; | ||
|
||
document.write('It\'s working under a subapp'); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<script src="/subapp/bundle.js" type="text/javascript" charset="utf-8"></script> | ||
</head> | ||
<body> | ||
<h1>Example: Node.js API - Simple</h1> | ||
</body> | ||
</html> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
'use strict'; | ||
|
||
const path = require('path'); | ||
const Webpack = require('webpack'); | ||
const WebpackDevServer = require('../../lib/Server'); | ||
const webpackConfig = require('./webpack.config'); | ||
|
||
const compiler = Webpack(webpackConfig); | ||
const server = new WebpackDevServer(compiler, { | ||
stats: { | ||
colors: true | ||
}, | ||
contentBase: path.resolve(__dirname), | ||
watchContentBase: true, | ||
sockPath: '/subapp/sockjs-node', | ||
publicPath: '/subapp/', | ||
historyApiFallback: { | ||
disableDotRule: true, | ||
index: '/subapp/' | ||
} | ||
}); | ||
|
||
server.listen(8080, '127.0.0.1', () => { | ||
console.log('Starting server on http://localhost:8080'); | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
'use strict'; | ||
|
||
module.exports = { | ||
context: __dirname, | ||
entry: ['./app.js', '../../client/index.js?http://localhost:8080/&sockPath=subapp/sockjs-node'], | ||
output: { | ||
filename: 'bundle.js', | ||
publicPath: '/subapp/' | ||
} | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -51,6 +51,9 @@ | |
"socket": { | ||
"type": "string" | ||
}, | ||
"sockPath": { | ||
"type": "string" | ||
}, | ||
"watchOptions": { | ||
"type": "object" | ||
}, | ||
|
@@ -321,6 +324,7 @@ | |
"filename": "should be {String|RegExp|Function} (https://webpack.js.org/configuration/dev-server/#devserver-filename-)", | ||
"port": "should be {String|Number} (https://webpack.js.org/configuration/dev-server/#devserver-port)", | ||
"socket": "should be {String} (https://webpack.js.org/configuration/dev-server/#devserver-socket)", | ||
"sockPath": "should be {String} (https://webpack.js.org/configuration/dev-server/#devserver-sockPath)", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This needs to be documented by opening a PR in docs repo please. Currently to URL redirects to the dev server 'landing page', which might be confusing for some and ultimately isn't really helpful |
||
"watchOptions": "should be {Object} (https://webpack.js.org/configuration/dev-server/#devserver-watchoptions)", | ||
"writeToDisk": "should be {Boolean|Function} (https://github.com/webpack/webpack-dev-middleware#writetodisk)", | ||
"headers": "should be {Object} (https://webpack.js.org/configuration/dev-server/#devserver-headers-)", | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Disagree, no need rewrite full package name to short name.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
qs
also conflicts with another variable in the file, and eslint complains about shadowing. That's why it's been renamed from the original PR.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@trescenzi you did everything right, do not rename