@@ -10,7 +10,6 @@ var https = require("https");
1010var httpProxyMiddleware = require ( "http-proxy-middleware" ) ;
1111var serveIndex = require ( "serve-index" ) ;
1212var historyApiFallback = require ( "connect-history-api-fallback" ) ;
13- var pkg = require ( "../package.json" ) ;
1413
1514function Server ( compiler , options ) {
1615 // Default options
@@ -48,6 +47,10 @@ function Server(compiler, options) {
4847 var inlinedJs = new StreamCache ( ) ;
4948 fs . createReadStream ( path . join ( __dirname , ".." , "client" , "index.bundle.js" ) ) . pipe ( inlinedJs ) ;
5049
50+ // Prepare the sockjs js file
51+ var sockjsJs = new StreamCache ( ) ;
52+ fs . createReadStream ( path . join ( __dirname , ".." , "client" , "sockjs.bundle.js" ) ) . pipe ( sockjsJs ) ;
53+
5154 // Init express server
5255 var app = this . app = new express ( ) ;
5356
@@ -59,6 +62,11 @@ function Server(compiler, options) {
5962 liveJs . pipe ( res ) ;
6063 } ) ;
6164
65+ app . get ( "/__webpack_dev_server__/sockjs.bundle.js" , function ( req , res ) {
66+ res . setHeader ( "Content-Type" , "application/javascript" ) ;
67+ sockjsJs . pipe ( res ) ;
68+ } ) ;
69+
6270 app . get ( "/webpack-dev-server.js" , function ( req , res ) {
6371 res . setHeader ( "Content-Type" , "application/javascript" ) ;
6472 inlinedJs . pipe ( res ) ;
@@ -335,9 +343,8 @@ Server.prototype.setContentHeaders = function(req, res, next) {
335343Server . prototype . listen = function ( ) {
336344 var returnValue = this . listeningApp . listen . apply ( this . listeningApp , arguments ) ;
337345 var sockServer = sockjs . createServer ( {
338- // The SockJS server package uses a version of the client script
339- // that doesn't match our version of the client script.
340- sockjs_url : 'https://cdn.jsdelivr.net/sockjs/' + pkg . dependencies [ 'sockjs-client' ] + '/sockjs.min.js' ,
346+ // Use provided up-to-date sockjs-client
347+ sockjs_url : "/__webpack_dev_server__/sockjs.bundle.js" ,
341348 // Limit useless logs
342349 log : function ( severity , line ) {
343350 if ( severity === "error" ) {
0 commit comments