Skip to content

Latest commit

 

History

History
61 lines (47 loc) · 1.31 KB

README.md

File metadata and controls

61 lines (47 loc) · 1.31 KB

@deskbtm/dev-mkcert

Use mkcert to provide certificate support for https development services.

Quick start

  1. Installation dependencies
yarn add @deskbtm/dev-mkcert -D
  1. Configure webpack
const { mkcert } = require('..');
const HTML = require('html-webpack-plugin');
const path = require('path');

/**
 * @type {import('webpack').Configuration}
 */
module.exports = async function () {
  const cert = await mkcert();

  return {
    context: __dirname,
    mode: 'development',
    entry: './main.js',
    plugins: [
      new HTML({
        template: path.resolve(__dirname, './index.html'),
        minify: false,
        filename: 'index.html',
      }),
    ],
    devServer: {
      host: 'localhost',
      port: 3000,
      server: {
        type: 'https',
        options: cert,
      },
    },
  };
};

Principle

Use mkcert to install the local CA certificate and generate it for server.https Server certificate.

Friendly reminder

  1. Uninstall the CA certificate: mkcert -uninstall

Thanks