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

强颜欢笑 提交于 2019-12-03 06:50:25

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 <script src="https://localhost:8080/webpack-dev-server.js"></script>
  • 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.

RIdotCOM

I think you might add this line to the entry point to also create a secure socket connection:

"dev-server": "webpack-dev-server/client?https://localhost:8080/",
Gurudath BN

I used like this in package.json and started working with port i needed:

"scripts": {
  "serve": "webpack-dev-server --inline --colors --watch --display-error-details --display-cached  --port 3001 --hot"
},
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!