Skip to content

Commit

Permalink
Merge pull request #3 from pengzhanbo/define-mock-data
Browse files Browse the repository at this point in the history
feat: add defineMockData
  • Loading branch information
pengzhanbo authored Sep 7, 2024
2 parents ff88e49 + c6a3b3c commit 37775fe
Show file tree
Hide file tree
Showing 16 changed files with 644 additions and 724 deletions.
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"cSpell.words": [
"mockjs",
"picocolors",
"rsbuild",
"rspack"
]
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ Implement a mock-dev-server in `rspack` and `rsbuild` that is fully consistent w
<p align="center">
<a href="https://www.npmjs.com/package/rspack-plugin-mock"><img alt="npm" src="https://img.shields.io/npm/v/rspack-plugin-mock?style=flat-square&colorA=564341&colorB=EDED91"></a>
<img alt="node-current" src="https://img.shields.io/node/v/rspack-plugin-mock?style=flat-square&colorA=564341&colorB=EDED91">
<img alt="npm peer dependency version" src="https://img.shields.io/npm/dependency-version/rspack-plugin-mock/peer/@rspack/core?style=flat-square&colorA=564341&colorB=EDED91">
<img alt="npm peer dependency version" src="https://img.shields.io/npm/dependency-version/rspack-plugin-mock/peer/@rsbuild/core?style=flat-square&colorA=564341&colorB=EDED91">
<img alt="npm peer dependency version" src="https://img.shields.io/npm/dependency-version/rspack-plugin-mock/peer/@rspack/core?style=flat-square&colorA=564341&colorB=EDED91&label=rspack">
<img alt="npm peer dependency version" src="https://img.shields.io/npm/dependency-version/rspack-plugin-mock/peer/@rsbuild/core?style=flat-square&colorA=564341&colorB=EDED91&label=rsbuild">
<img alt="npm" src="https://img.shields.io/npm/dm/rspack-plugin-mock?style=flat-square&colorA=564341&colorB=EDED91">
<img alt="GitHub Workflow Status" src="https://img.shields.io/github/actions/workflow/status/pengzhanbo/rspack-plugin-mock/lint.yml?style=flat-square&colorA=564341&colorB=EDED91">
</p>
Expand Down
4 changes: 2 additions & 2 deletions README.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
<p align="center">
<a href="https://www.npmjs.com/package/rspack-plugin-mock"><img alt="npm" src="https://img.shields.io/npm/v/rspack-plugin-mock?style=flat-square&colorA=564341&colorB=EDED91"></a>
<img alt="node-current" src="https://img.shields.io/node/v/rspack-plugin-mock?style=flat-square&colorA=564341&colorB=EDED91">
<img alt="npm peer dependency version" src="https://img.shields.io/npm/dependency-version/rspack-plugin-mock/peer/@rspack/core?style=flat-square&colorA=564341&colorB=EDED91">
<img alt="npm peer dependency version" src="https://img.shields.io/npm/dependency-version/rspack-plugin-mock/peer/@rsbuild/core?style=flat-square&colorA=564341&colorB=EDED91">
<img alt="npm peer dependency version" src="https://img.shields.io/npm/dependency-version/rspack-plugin-mock/peer/@rspack/core?style=flat-square&colorA=564341&colorB=EDED91&label=rspack">
<img alt="npm peer dependency version" src="https://img.shields.io/npm/dependency-version/rspack-plugin-mock/peer/@rsbuild/core?style=flat-square&colorA=564341&colorB=EDED91&label=rsbuild">
<img alt="npm" src="https://img.shields.io/npm/dm/rspack-plugin-mock?style=flat-square&colorA=564341&colorB=EDED91">
<img alt="GitHub Workflow Status" src="https://img.shields.io/github/actions/workflow/status/pengzhanbo/rspack-plugin-mock/lint.yml?style=flat-square&colorA=564341&colorB=EDED91">
</p>
Expand Down
2 changes: 1 addition & 1 deletion examples/rsbuild-starter/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"preview": "rsbuild preview"
},
"devDependencies": {
"@rsbuild/core": "1.0.1-beta.9",
"@rsbuild/core": "1.0.1-rc.5",
"@types/mockjs": "^1.0.10",
"mockjs": "^1.1.0",
"rspack-plugin-mock": "workspace:*"
Expand Down
7 changes: 7 additions & 0 deletions examples/rsbuild-starter/rsbuild.config.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
import path from 'node:path'
import { fileURLToPath } from 'node:url'
import { defineConfig } from '@rsbuild/core'
import { pluginMockServer } from 'rspack-plugin-mock/rsbuild'

export default defineConfig({
html: {
template: './index.html',
},
source: {
alias: {
'@': path.resolve(path.dirname(fileURLToPath(import.meta.url)), './src'),
},
},
server: {
proxy: {
'/api': 'http://localhost:8080',
Expand Down
4 changes: 2 additions & 2 deletions examples/rspack-starter/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
"build": "cross-env NODE_ENV=production rspack build"
},
"devDependencies": {
"@rspack/cli": "1.0.0-beta.2",
"@rspack/core": "1.0.0-beta.2",
"@rspack/cli": "^1.0.3",
"@rspack/core": "^1.0.3",
"@types/mockjs": "^1.0.10",
"cross-env": "^7.0.3",
"mockjs": "^1.1.0",
Expand Down
4 changes: 3 additions & 1 deletion examples/rspack-starter/rspack.config.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// @ts-check

import path from 'node:path'
import { fileURLToPath } from 'node:url'
import { rspack } from '@rspack/core'
import { MockServerPlugin } from 'rspack-plugin-mock'

Expand All @@ -13,7 +15,7 @@ export default {
resolve: {
extensions: ['.js', '.ts'],
alias: {
'@': './src',
'@': path.resolve(path.dirname(fileURLToPath(import.meta.url)), './src'),
},
},
devServer: {
Expand Down
26 changes: 13 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "rspack-plugin-mock",
"type": "module",
"version": "0.3.4",
"packageManager": "pnpm@9.6.0",
"packageManager": "pnpm@9.9.0",
"description": "inject api mock server to development server",
"author": "pengzhanbo <[email protected]> (https://github.com/pengzhanbo)",
"license": "MIT",
Expand Down Expand Up @@ -102,37 +102,37 @@
"co-body": "^6.2.0",
"cookies": "^0.9.1",
"cors": "^2.8.5",
"debug": "^4.3.6",
"debug": "^4.3.7",
"fast-glob": "^3.3.2",
"formidable": "2.1.2",
"http-status": "^1.7.4",
"is-core-module": "^2.15.0",
"is-core-module": "^2.15.1",
"json5": "^2.2.3",
"memfs": "^4.11.1",
"mime-types": "^2.1.35",
"path-to-regexp": "^7.1.0",
"picocolors": "^1.0.1",
"path-to-regexp": "7.1.0",
"picocolors": "^1.1.0",
"portfinder": "^1.0.32",
"ws": "^8.18.0"
},
"devDependencies": {
"@pengzhanbo/eslint-config": "^1.12.0",
"@rsbuild/core": "1.0.1-beta.9",
"@rspack/core": "1.0.0-beta.2",
"@pengzhanbo/eslint-config": "^1.15.0",
"@rsbuild/core": "1.0.1-rc.5",
"@rspack/core": "^1.0.3",
"@types/co-body": "^6.1.3",
"@types/cookies": "^0.9.0",
"@types/cors": "^2.8.17",
"@types/debug": "^4.1.12",
"@types/formidable": "2.0.6",
"@types/is-core-module": "^2.2.2",
"@types/mime-types": "^2.1.4",
"@types/node": "^22.1.0",
"@types/node": "^22.5.4",
"@types/ws": "^8.5.12",
"bumpp": "^9.4.2",
"bumpp": "^9.5.2",
"conventional-changelog-cli": "^5.0.0",
"eslint": "^9.8.0",
"husky": "^9.1.4",
"lint-staged": "^15.2.8",
"eslint": "^9.10.0",
"husky": "^9.1.5",
"lint-staged": "^15.2.10",
"tsup": "^8.2.4",
"typescript": "^5.5.4"
},
Expand Down
Loading

0 comments on commit 37775fe

Please sign in to comment.