First be sure to know what is HAR file reading wikipedia.
This package expose a CLI to create an HTTP mock server and a library API to integrate it in webpack devServer
So you have an HAR file ? You can either:
- configure webpack to use the har file directly
- start a server using the CLI
So in your webpack.config.dev.js file you can do the following:
const har = require('har-express');
if (process.env.HAR) {
devServer.before = app => {
app.use(har.getMiddleware(process.env.HAR));
};
} else {
// fallback for dev in your proxy to the real backend
devServer.proxy = {
'/api': process.env.API_URL || 'http://localhost:8000',
};
}
module.exports = {
devServer,
};
then you can start your project using
HAR='./use-case.har' yarn start
In the context your webpack config use API_URL env to configure the proxy just do
API_URL=http://localhost:8000 yarn start
har-express -p 8000 ./use-case.har