Use mkcert to provide certificate support for https development services.
- Installation dependencies
yarn add @deskbtm/dev-mkcert -D
- 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,
},
},
};
};
Use mkcert to install the local CA
certificate and generate it for server.https Server certificate.
- Uninstall the
CA
certificate:mkcert -uninstall