2021-02-09 23:47:14 +08:00
|
|
|
/**
|
|
|
|
* Mock plugin for development and production.
|
|
|
|
* https://github.com/anncwb/vite-plugin-mock
|
|
|
|
*/
|
2021-01-09 23:28:52 +08:00
|
|
|
import { viteMockServe } from 'vite-plugin-mock';
|
2020-12-13 21:17:37 +08:00
|
|
|
|
2021-02-08 23:59:47 +08:00
|
|
|
export function configMockPlugin(isBuild: boolean) {
|
|
|
|
return viteMockServe({
|
|
|
|
ignore: /^\_/,
|
|
|
|
mockPath: 'mock',
|
|
|
|
localEnabled: !isBuild,
|
|
|
|
prodEnabled: isBuild,
|
|
|
|
injectCode: `
|
2021-01-22 22:42:27 +08:00
|
|
|
import { setupProdMockServer } from '../mock/_createProductionServer';
|
|
|
|
|
|
|
|
setupProdMockServer();
|
|
|
|
`,
|
2021-02-08 23:59:47 +08:00
|
|
|
});
|
2020-12-13 21:17:37 +08:00
|
|
|
}
|