Skip to content

Commit

Permalink
feat: adding json-server mock only when running on dev mode
Browse files Browse the repository at this point in the history
  • Loading branch information
willmendesneto committed Dec 17, 2023
1 parent 0a6be6f commit 75b6513
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions vite.config.ts
@@ -1,24 +1,29 @@
import path from 'node:path';

import react from '@vitejs/plugin-react';
import { defineConfig } from 'vite';
import { defineConfig, PluginOption } from 'vite';
import jsonServer from 'vite-plugin-simple-json-server';

// https://vitejs.dev/config/
export default defineConfig(() => {
export default defineConfig(({ mode }) => {
const plugins: PluginOption[] = [react()];

if (mode === 'development') {
plugins.push(
jsonServer({
mockDir: 'mock',
urlPrefixes: ['/api'],
}),
);
}

return {
build: {
modulePreload: {
polyfill: true,
},
},
plugins: [
react(),
jsonServer({
mockDir: 'mock',
urlPrefixes: ['/api'],
}),
],
plugins,
test: {
globals: true,
environment: 'jsdom',
Expand Down

0 comments on commit 75b6513

Please sign in to comment.