Skip to content

Webpack 快速开始

1. 安装

bash
pnpm add -D mokup
bash
npm install -D mokup
bash
yarn add -D mokup
bash
bun add -d mokup

2. 添加插件

js
const { mokupWebpack } = require('mokup/webpack')

const withMokup = mokupWebpack({
  entries: {
    dir: 'mock',
    prefix: '/api',
  },
})

module.exports = withMokup({})

3. 启动开发服务

启动 webpack dev server:

bash
pnpm webpack serve
bash
npm exec webpack serve
bash
yarn webpack serve
bash
bunx webpack serve

4. 验证

  • http://localhost:8080/api/users
  • http://localhost:8080/__mokup

下一步

完整选项请参考 Webpack 插件