webpack-dev-server 2.5.1在传入的https请求中立即退出

问题描述

我正在尝试运行一些可以在webpack-dev-server上正常运行的打字稿应用程序,只要它在http上运行即可。 一旦我切换到https(公告或创建的证书),服务器就会在我尝试加载页面时崩溃(浏览器安全警告->高级->继续执行127.0.0.1->爆炸)

我正在使用以下设备运行开发服务器:

"webpack-dashboard -- webpack-dev-server --open --https --cert ./cert/private.pem --key ./cert/private.key --config ./webpack.config.js"

崩溃后,我找不到崩溃的日志输出。 有什么方向,提示,技巧可以告诉我下一个地方/这里我做错了什么?

webpack.config.js可以与http完美运行,但不能与https

一起运行
const webpack = require("webpack");
const path = require("path");
const Dashboardplugin = require("webpack-dashboard/plugin");
const nodeenv = process.env.NODE_ENV || "development";
const isProd = nodeenv === "production";
const HtmlWebpackPlugin = require('html-webpack-plugin')

const plugins = [
  new webpack.DefinePlugin({
    "process.env": {
      // eslint-disable-line quote-props
      NODE_ENV: JSON.stringify(nodeenv)
    }
  }),new webpack.LoaderOptionsPlugin({
    options: {
      tslint: {
        emitErrors: true,failOnHint: true
      }
    }
  }),new HtmlWebpackPlugin({
    template: 'src/index.html'
  })
];

if (!isProd) {
  plugins.push(new Dashboardplugin());
}

var config = {
  devtool: isProd ? "hidden-source-map" : "source-map",context: path.resolve("./"),entry: {
    app: "./src/index.ts"
  },output: {
    path: path.resolve("./dist"),filename: "index.js",sourceMapFilename: "index.map",devtoolmodulefilenameTemplate: function(info) {
      return "file:///" + info.absoluteResourcePath;
    }
  },module: {
    rules: [
      {
        enforce: "pre",test: /\.ts?$/,exclude: ["node_modules"],use: ["awesome-typescript-loader","source-map-loader"]
      },{
        test: /\.(js|ts)$/,loader: "babel-loader",exclude: [/\/node_modules\//]
      },{
        test: /\.html$/,loader: "raw-loader" // loaders: ['raw-loader'] is also perfectly acceptable.
      }
    ]
  },resolve: {
    extensions: [".ts",".js"]
  },plugins: plugins,devServer: {
    host: '0.0.0.0',contentBase: path.join(__dirname,'/src'),compress: true,port: 3001,hot: true,disableHostCheck: true,watchContentBase: true,},stats: 'detailed',};

module.exports = config;

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)