Skip to content

nawbc/dev-mkcert

 
 

Repository files navigation

@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

About

Provide certificates for https dev service.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • TypeScript 91.0%
  • JavaScript 6.4%
  • HTML 2.6%