How to run Webpack Dev Server --https --hot --inline

后端 未结 3 1372
时光说笑
时光说笑 2021-02-09 00:00

Is there a way to leverage running the webpack-dev-server on https when configuring using CLI?

The problem is the connection to socket.io is

3条回答
  •  南方客
    南方客 (楼主)
    2021-02-09 00:37

    Yes there is a way to configure webpack-dev-server on https when configuring using CLI.

    The solution is to not use --inline option.

    There are many ways to configure the server and --hot. The one to follow, assuming your not creating a custom server implementation/middleware (Might be the same), is detailed in the docs.

    http://webpack.github.io/docs/webpack-dev-server.html#webpack-dev-server-cli

    • Do not include
    • Do not include webpack/hot/only-dev-server into the entry.

    package.json

    {
      "scripts": {
        "start": "webpack-dev-server -d --hot --https --config webpack.config.development.js"
      }
    }
    

    webpack.config.development.js

    var webpackConfig = require('webpack-config');
    
    module.exports = webpackConfig.fromCwd().merge({
        devServer: {
            colors:             true,
            contentBase:        './build',
            historyApiFallback: true,
            inline:             true,
            progress:           true
        },
    
        devtool: 'eval-source-map'
    });
    

    Main webpack configuration is not listed here.

提交回复
热议问题