Webpack-dev-server: Possible to configure sockjs url?

Created on 29 Dec 2017  路  4Comments  路  Source: webpack/webpack-dev-server

I have a very simple setup of the webpack-dev-server running on port 8080 behind an nginx proxy listening on port 80 and routing traffic to the upstream server. However, I'm getting lots of console log errors when the server tries to access the sock.js instance:

 http://wepackserver.localhost:8080/sockjs-node/info?t=1514563803767

Is is possible to configure the setup of sock.js to go straight to:

http://wepackserver.localhost/sockjs-node/info?t=1514563803767

I've looked at the documentation and tried using the proxy option, but nothing seems to work.

Here is my config, created by the vue-cli package using the webpack-simple template:

var path = require('path')
var webpack = require('webpack')

module.exports = {
  entry: './src/app.js',
  output: {
    path: path.resolve(__dirname, './dist'),
    publicPath: '/dist/',
    filename: 'build.js'
  },
  module: {
    rules: [
      {
        test: /\.css$/,
        use: [
          'vue-style-loader',
          'css-loader'
        ]
      },
      {
        test: /\.vue$/,
        loader: 'vue-loader',
        options: {
          loaders: {
          }
          // other vue-loader options go here
        }
      },
      {
        test: /\.js$/,
        loader: 'babel-loader',
        exclude: /node_modules/
      },
      {
        test: /\.(png|jpg|gif|svg)$/,
        loader: 'file-loader',
        options: {
          name: '[name].[ext]?[hash]'
        }
      }
    ]
  },
  resolve: {
    alias: {
      'vue$': 'vue/dist/vue.esm.js'
    },
    extensions: ['*', '.js', '.vue', '.json']
  },
  devServer: {
    historyApiFallback: true,
    noInfo: true,
    overlay: true,
    port: 8080,
    host: '0.0.0.0',
    disableHostCheck: true
  },
  performance: {
    hints: false
  },
  devtool: '#eval-source-map'
}

if (process.env.NODE_ENV === 'production') {
  module.exports.devtool = '#source-map'
  // http://vue-loader.vuejs.org/en/workflow/production.html
  module.exports.plugins = (module.exports.plugins || []).concat([
    new webpack.DefinePlugin({
      'process.env': {
        NODE_ENV: '"production"'
      }
    }),
    new webpack.optimize.UglifyJsPlugin({
      sourceMap: true,
      compress: {
        warnings: false
      }
    }),
    new webpack.LoaderOptionsPlugin({
      minimize: true
    })
  ])
}

Most helpful comment

All 4 comments

Closing - not sure how I missed the 'public' configuration property.

Hey @leepowellcouk !
I am having this issue, can you elaborate on what exactly the 'public' configuration property is?
Thanks in advance.

same ^

Was this page helpful?
0 / 5 - 0 ratings

Related issues

gimmi picture gimmi  路  3Comments

daryn-k picture daryn-k  路  3Comments

piotrszaredko picture piotrszaredko  路  3Comments

hnqlvs picture hnqlvs  路  3Comments

Ky6uk picture Ky6uk  路  3Comments