Skip to content

devServer.public not used by hot-update.json #1591

@yamsellem

Description

@yamsellem
  • Operating System: debian stretch
  • Node Version: 6.11.1
  • NPM Version: 3.10.10
  • webpack Version: 4.27.0
  • webpack-dev-server Version: 3.1.10
  • This is a bug
  • This is a modification request

Configuring devServer.public to a custom domain only updates the hot-reload socket GET calls, but not the hot-modules GET calls. It seems that there are no ways to configure the later.

And no output.hotUpdateMainFilename nor hotUpdateChunkFilename do allows absolute path.

Code

'use strict';

const webpack = require('webpack');
const VueLoaderPlugin = require('vue-loader').VueLoaderPlugin;
const MiniCssExtractPlugin = require('mini-css-extract-plugin');

const path = require('path');

function resolve(dir) {
  return path.join(__dirname, '..', dir);
}

const env = process.env.NODE_ENV === 'production' ? 'production' : 'development';

module.exports = {
  mode: env,
  target: 'web',
  output: {
    publicPath: '/',
    path: path.resolve(__dirname, './build'),
    filename: '[name].js',
    hotUpdateMainFilename: '__hmr/[hash].hot-update.json',
    hotUpdateChunkFilename: '__hmr/[id].[hash].hot-update.js'
  },
  devtool: env === 'production' ? false : 'eval-source-map',
  resolve: {
    extensions: ['.js', '.vue', '.json']
  },
  devServer: {
    hot: true,
    hotOnly: true,
    inline: true,
    host: '0.0.0.0',
    public: 'hotreload.dev',
    port: 80,
    disableHostCheck: true,
    quiet: true
  },
  module: {
    rules: [
      {
        test: /\.vue$/,
        loader: 'vue-loader'
      },
      {
        test: /\.js$/,
        loader: 'babel-loader',
        include: [resolve('src'), resolve('test')]
      },
      {
        test: /\.css$/,
        use: [
          'vue-style-loader',
          'css-loader',
          'sass-loader'
        ]
      },
      {
        test: /\.(png|jpe?g|gif|svg)(\?.*)?$/,
        loader: 'url-loader',
        options: {
          limit: 10000,
          name: 'img/[name].[hash:7].[ext]'
        }
      }
    ]
  },
  plugins: [
    // http://vuejs.github.io/vue-loader/en/workflow/production.html
    new webpack.DefinePlugin({
      WEBPACK_ENV: JSON.stringify(env)
    }),
    new VueLoaderPlugin(),
    // extract css into its own file
    new MiniCssExtractPlugin({
      filename: 'css/[name].[chunkhash].css',
      chunkFilename: 'css/[id].[chunkhash].css'
    })
  ]
};

Expected Behavior

Webapp should be served from http://localhost
Sockjs should be served from http://hotreload.dev/sockjs-node/info?t=1544113470603
Websocket should be served from ws://hotreload.dev/sockjs-node/571/zjz3ymti/websocket
HMR should be served from http://hotreload.dev/__hmr/e70392ebad328cc520e6.hot-update.json

Actual Behavior

Webapp is served from http://localhost
Sockjs is served from http://hotreload.dev/sockjs-node/info?t=1544113470603
Websocket is served from ws://hotreload.dev/sockjs-node/571/zjz3ymti/websocket
HMR is served from http://localhost/__hmr/e70392ebad328cc520e6.hot-update.json

For Bugs; How can we reproduce the behavior?

webpack-dev-server --config webpack.conf.js --hot --progress -d

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions