This code demo uses webpack's dev-server middleware to return mocked HTTP responses.
- Go to the
/code-demos/webpack-dev-server-middleware
folder. - Run
npm i
to install all the packages. - Run
npm start
to start the app which will be available on http://localhost:4201.
This solution requires extending Angular's Webpack configuration. To do the code demo used the ngx-build-plus npm package and created a webpack.config.js file where the middleware that returns mocked responses is defined. The webpack.config.js
is set as an extraWebpackConfig
to use int the angular.json file.
Warning
This solution is dependent on using Webpack as your bundler. Angular 16 brings a preview support for using vite. If you wanted to use vite, this solution would not work.