We are going to create a developer environment template that bundles:
A SPA (Single Page Application) dev server (we'll use Vite as an example, but the idea is to be generic).
Domain mocks (for backend API mocking, we can use something like msw or json-server).
Feature store fakes (for state management, we can provide a way to fake the store, e.g., for Redux or Zustand).
We'll structure the project as a monorepo or a single project with multiple packages? Actually, let's keep it simple: one project that can be cloned and run.
Steps:
Initialize a project (we'll use npm, but you can adapt to yarn or pnpm).
Set up the SPA dev server with Vite (assuming React for example, but we can make it generic).
Set up a mock server for API calls (using msw, which works at the network level and can be used in both browser and node).
Set up a way to fake the feature store (we'll create a mock store that can be swapped in development).
However, note that the requirement is for a template. So we want to create a template that can be used for any SPA project.
Let's design:
The template will have a src directory for the SPA code.
We'll have a mocks directory for the mock server and mock data.
We'll have a store directory (or src/store) for the state management, and we'll provide a way to use a fake store in development.
But note: the template should be generic, so we might not want to enforce a specific state management library.
Approach:
We can create a template that uses:
Vite for the dev server and build.
MSW for API mocking.
For the store, we can provide an example with a simple context or a specific library, but also show how to swap.
However, the requirement says "feature store fakes", meaning we want to have a fake implementation of the store for development.
Let's break down:
SPA dev server: Vite.
Domain mocks: MSW (mock service worker) to intercept HTTP requests and return mock data.
Feature store fakes: We can create a mock store that mimics the real store but with fake data. We can use dependency injection or simply conditionally import.
But to keep it simple and generic, we can:
In the store setup, we check the environment (development) and then use a fake store if a flag is set.
However, that might not be the best because we want to have the fake store only in development and for certain features.
Alternatively, we can structure:
Have a store module that exports the real store and a fake store.
In the app, we conditionally use the fake store when in development and a flag is set (maybe via environment variable).
But then, how do we inject the fake store? We can do:
However, this might not be ideal if we want to switch stores at runtime.
Alternatively, we can use a factory pattern and let the dev server provide the fake store.
Since we are bundling everything in one dev environment, we can:
Start the SPA dev server (Vite) and the mock server (MSW) together.
The SPA will use the fake store by default in development.
But note: the fake store might be just a different implementation of the same interface.
Let's create a template with:
A Vite project (with React, but we can also do Vue or vanilla JS? The template should be adaptable).
MSW set up to handle API requests.
A simple store example (using React Context for simplicity, but we can also show Redux or Zustand if needed).
However, the requirement is for a template, so we should make it as generic as possible.
Steps for the template:
Create a new Vite project (we'll use React for the example, but we can note that it can be changed).
Install msw and set it up.
Create a simple store (using React Context) and then create a fake version of it.
But wait, the requirement says "feature store fakes". This might be more about having a store that is preloaded with fake data for development, not necessarily a different implementation.
So we can:
Have a real store that is used in production.
In development, we can use the same store but preloaded with fake data, or we can have a separate fake store that mocks the actions and state.
Let's assume we want to mock the entire store for development, so that we don't have to worry about the real API and we can develop the UI independently.
We can do:
In development, we use MSW to mock the API, and we also use a fake store that doesn't even try to call the API and returns static data.
But then, the store might be making API calls? So if we mock the API, the store can be the same, but if we want to avoid even the store's API calls, we can have a fake store.
However, if we mock the API at the network level (with MSW), then the store can remain the same and we don't need a fake store?
But the requirement says both: domain mocks (which I interpret as API mocks) and feature store fakes.
So maybe:
Domain mocks: for when the store makes API calls, we intercept and return mock data.
Feature store fakes: we replace the store with a version that doesn't do any async and just returns static data, or maybe we want to test the store in isolation without the network.
Actually, they might be two different things:
Domain mocks: at the network level, so any HTTP request gets a mock response.
Feature store fakes: at the state management level, so we don't even have to set up the store correctly, we just set the state to what we need for a feature.
But note: if we use MSW, then the store will work as usual but get mock responses. So why do we need a fake store?
Maybe for:
Performance: don't want to run the store's logic (like reducers) and just set the state directly.
Isolating the component from the store: we want to test a component without the store, so we provide a fake store that only has the necessary state.
However, in development, we are usually developing the component with the store. So maybe the fake store is for when we want to develop a component in isolation (like a storybook) but without the entire store.
But the requirement says "developer environment template", so maybe it's for local development of the entire app.
Let's re-read: "bundling SPA dev server, domain mocks, and feature store fakes"
So we want:
SPA dev server: to run the app.
Domain mocks: to mock the backend.
Feature store fakes: to fake the store (maybe for specific features or globally).
I think the idea is to have a development environment where:
The app runs with a dev server.
The backend is mocked (so we don't need a real server).
The store is faked (so we don't need to set up the real store with all its middleware, reducers, etc. and we can have predefined state).
How about:
We create a template that has:
A Vite project.
MSW for mocking network requests.
A store that in development uses a fake implementation (maybe a simple object with the state and actions that just set the state without any async) and in production uses the real store.
But then, if we are already mocking the network, why fake the store? Because the store might have complex logic (like reducers, sagas, etc.) that we don't want to run in development for a particular feature.
Alternatively, we can have:
The real store, but we preload it with initial state that is fake (from a fixture). This is common in development.
So maybe "feature store fakes" means we can have a way to set the initial state of the store to a fake one for a given feature.
Let's design:
We'll have:
src/store/index.js that exports the real store (with all the reducers, middleware, etc.)
src/store/fake.js that exports a fake store (maybe a simple object or a store with a different implementation that uses a predefined state and actions that don't do anything or just log).
Then, in the app entry point:
code
import { createStore } from './store';
import { createFakeStore } from './store/fake';
const store = process.env.NODE_ENV === 'development' && process.env.USE_FAKE_STORE
? createFakeStore()
: createStore();
But we want to be able to switch per feature? That might be too complex.
Alternatively, we can have a way to set the initial state of the real store to a fake one, and then we don't need a separate store.
However, the requirement says "feature store fakes", which might imply that for a given feature (maybe a route or a component) we want to use a fake store.
This sounds like we want to be able to swap the store at a feature level, which is more advanced.
Given the complexity, let's stick to a simpler approach:
We'll provide:
code
- A way to run the app with a fake store (for the entire app) in development.
- A way to run the app with the real store but with mocked network (using MSW).
And we can combine both: in development, we use the fake store and MSW.
But note: if we use the fake store, we might not need MSW because the fake store doesn't make network calls. But the requirement says both, so maybe we want to be able to use:
code
- Real store + MSW (to test the store with mocked network)
- Fake store (and then MSW is not needed, but we can still run it and it won't be used)
So we can have two modes:
code
Mode 1: Development with fake store (and MSW running but not used by the fake store).
Mode 2: Development with real store and MSW (to test the store with mocked network).
How about:
code
We set up MSW to run in both modes, but in fake store mode, the store doesn't make network calls so MSW won't see any requests.
Alternatively, we can have two separate scripts:
code
"dev": "vite", // uses real store and MSW
"dev:fake": "vite --mode fake" // uses fake store and MSW (but MSW might not be used)
But then, how do we switch the store? We can use Vite's environment variables.
Let's do:
code
In `vite.config.js` we can define:
mode: process.env.NODE_ENV,
And then in the app, we check `import.meta.env.MODE` or `import.meta.env.VITE_USE_FAKE_STORE`.
But we want to have two different environments: development and development with fake store.
We can use Vite's --mode flag to set a mode, and then have a .env.fake file.
Steps:
code
- We have `.env` for development (with real store) and `.env.fake` for development with fake store.
But we also want to run MSW only when we are in development? Actually, we want MSW to run in both development modes because:
code
- In real store mode, we need MSW to mock the network.
- In fake store mode, we don't need MSW, but it doesn't hurt to run it.
However, we might want to run MSW only when we are using the real store? Not necessarily.
Let's set up:
code
We'll have:
- `src/main.jsx` (or `src/index.js` for vanilla) that sets up the app and the store.
Example:
import { createRoot } from 'react-dom/client';
import App from './App';
import { createStore } from './store';
import { createFakeStore } from './store/fake';
import { setupWorker } from './mocks/worker'; // MSW worker
const useFakeStore = import.meta.env.VITE_USE_FAKE_STORE === 'true';
const store = useFakeStore ? createFakeStore() : createStore();
// If we are in development and using the real store, we start the MSW worker.
// But note: we might want to start MSW even in fake store mode? Actually, if we are using fake store, we don't need MSW.
// But what if the app has some parts that don't use the store and make direct fetch? Then we might want MSW.
// So let's start MSW in both development modes.
if (import.meta.env.DEV) {
const { worker } = setupWorker();
worker.start();
}
const root = createRoot(document.getElementById('root'));
root.render(<App store={store} />);
But wait, if we are using React, we might be using a Provider for the store. So we can do:
Step 6: Create .env and .env.fake? Actually, we are setting the environment variable in the script, so we don't need .env files for this flag.
But we might have other environment variables. We can have:
code
.env: for development (real store)
.env.fake: for development with fake store? But we are setting VITE_USE_FAKE_STORE in the script, so we don't need a separate file.
Alternatively, we can have:
code
In `.env`:
VITE_USE_FAKE_STORE=false
In `.env.fake`:
VITE_USE_FAKE_STORE=true
And then in the script:
"dev": "vite",
"dev:fake": "vite --mode fake"
And Vite will load `.env.fake` when we use `--mode fake`.
But note: Vite by default loads .env for development and .env.production for production. We are adding a custom mode fake which is also development? We can set:
code
In `vite.config.js`:
export default defineConfig({
mode: process.env.NODE_ENV, // but we are overriding with --mode
// ... other config
});
Actually, when we run vite --mode fake, it will load .env.fake and set import.meta.env.MODE to 'fake'.
But we don't want to rely on the mode, we want to rely on the variable.
Alternatively, we set in .env.fake:
code
VITE_USE_FAKE_STORE=true
And then in the script:
code
"dev:fake": "vite --mode fake"
And in .env (for normal development) we set:
code
VITE_USE_FAKE_STORE=false
But note: we don't want to commit the .env.fake with VITE_USE_FAKE_STORE=true because it's a development file? Actually, we can have a .env.example and then each developer copies to .env and sets their own.
But for the template, we can provide:
code
.env.example:
VITE_USE_FAKE_STORE=false
And then for fake mode, we create `.env.fake` with:
VITE_USE_FAKE_STORE=true
Step 7: Update the template with instructions in README.
Let's write the code for the template.
However, note: the above approach uses React and React Context. We want to be generic? The template can be for any framework, but we are using React as an example.
We can note that the store setup can be adapted to any state management.
Let's write the files:
File: src/store/index.js (real store)
We'll use React Context and useReducer as an example.
File: src/store/fakeInitialState.js
File: src/mocks/browser.js and src/mocks/handlers.js
File: src/main.jsx (entry point)
We'll adjust the Vite template's main.jsx and App.jsx accordingly.
Let's assume we are starting from a Vite React template.
Steps:
Create the project with Vite (React template).
Install msw.
Create the store files.
Create the mocks.
Update main.jsx to conditionally use fake initial state and start MSW.
Update package.json with the dev:fake script.
Create .env and .env.fake (or .env.example and .env.fake) with the appropriate variables.
import { initialState as realInitialState } from './index';
// We can override parts of the real initial state with fake data.
export const fakeInitialState = {
...realInitialState,
user: { name: 'Fake User', id: 1 },
};
import { setupWorker } from 'msw';
import { handlers } from './handlers';
export const worker = setupWorker(...handlers);
src/main.jsx:
code
import React from 'react';
import ReactDOM from 'react-dom/client';
import App from './App';
import { StoreProvider } from './store';
import { worker } from './mocks/browser';
import { initialState as realInitialState } from './store';
import { fakeInitialState } from './store/fakeInitialState';
const useFakeStore = import.meta.env.VITE_USE_FAKE_STORE === 'true';
ReactDOM.createRoot(document.getElementById('root')).render(
<React.StrictMode>
<StoreProvider initialState={useFakeStore ? fakeInitialState : realInitialState}>
<App />
</StoreProvider>
</React.StrictMode>
);
if (import.meta.env.DEV) {
worker.start();
}
Now, we need to adjust vite.config.js to load the environment variables from .env.fake when in fake mode? Actually, Vite does that automatically when we use --mode fake.
But we need to set the mode to 'fake' in the script.
But we don't have to, because the default is false? Actually, if the variable is not set, it will be undefined. So we can set it in .env for development to be false, but then when we run dev:fake we override it.
Alternatively, we can just rely on the script setting the variable and not have .env for this variable.
We can remove the .env for this variable and just set it in the scripts.
Let's change:
code
In `main.jsx`:
const useFakeStore = import.meta.env.VITE_USE_FAKE_STORE === 'true';
And in `package.json`:
"dev": "vite", // no variable set, so useFakeStore will be false.
"dev:fake": "cross-env VITE_USE_FAKE_STORE=true vite"
Then we don't need a .env file for this variable.
But note: Vite by default loads .env and we might have other variables. So we can have .env for other variables and not set VITE_USE_FAKE_STORE there.
So we are good.
Let's write the template with these files.
However, note: the above store example is very simple and uses React. We want to be generic.
We can change the store example to be agnostic of the framework? Actually, the store is in the context of the SPA, so we are using React.
But if we want to support other frameworks, we would have to adjust.
Given the time, we'll provide a React example and note that the store can be adapted.
Alternatively, we can use a state management library like Redux and provide a fake store by having a different root reducer or initial state.
But the template should be simple.
Let's stick to React Context.
Now, the template is ready.
We also need to adjust the App.jsx to use the store.
Then, when we run in fake mode, the initial state will have a fake user, and when we click the button, it will change to 'Real User' because the reducer is still running.
If we want to completely fake the store (so that the button does nothing), we would need to change the StoreProvider to use a fake dispatch when in fake mode.
But the requirement says "feature store fakes", which might mean we want to fake the store for a feature, not necessarily the entire app.
Given the complexity of per-feature faking, we'll leave it as a global fake initial state and note that for per-feature faking, one could create multiple StoreProviders and conditionally render them.
Alternatively, we can extend the StoreProvider to accept an isFake prop and then use a fake dispatch (that does nothing) and a fixed state.
Now, when in fake mode, the store will have the fake initial state and any dispatch will be a no-op.
This is a more complete fake store.
Let's write the template accordingly.
Summary of the template:
We have a Vite project (React).
We have MSW set up to run in development and mock network requests.
We have a store that can be faked (with a fixed state and no-op dispatch) when the environment variable VITE_USE_FAKE_STORE is set to true.
Steps for the user:
code
1. Clone the template.
2. Run `npm install`.
3. Run `npm run dev` for development with real store and MSW.
4. Run `npm run dev:fake` for development with fake store and MSW (but note: the fake store doesn't make network calls, so MSW might not be used, but it's running).
We can also note that the user can adjust the fake initial state in src/store/fakeInitialState.js and the mocks in src/mocks/handlers.js.
Let's write the files in the template.
However, note: the template should be framework agnostic? We used React, but we can note that for other frameworks, the store setup would be different.
We can also provide an example with Zustand or Redux? But that would make the template more complex.
Given the instructions, we'll stick to React Context.
Let's create the template with the above structure and files.
We'll also update the README.md with instructions.
Now, write the code for each file.
Since we are generating a template, we can write the files as if we are creating a new project.
Let's do:
File: package.json (we start from Vite's template and adjust)
File: vite.config.js (from Vite template, we don't change much)
File: index.html (from Vite template)
File: src/App.jsx (as above, using the store)
File: src/main.jsx (as above, with MSW and StoreProvider)
File: src/store/index.js (as above, with the StoreProvider that supports fake mode)
File: src/store/fakeInitialState.js (as above)
File: src/mocks/handlers.js (as above)
File: src/mocks/browser.js (as above)
File: .env (optional, but we can leave empty or set other variables)
File: README.md:
code
# SPA Developer Environment Template
This template provides a SPA development environment with:
- Vite dev server
- MSW for API mocking
- A feature store that can be faked for development
## Setup
1. Clone the repository.
2. Run `npm install`.
## Development
- Run `npm run dev` to start the development server with the real store and MSW.
- Run `npm run dev:fake` to start the development server with a fake store (preloaded state and no-op dispatch) and MSW.
## Store
The store is implemented using React Context and `useReducer`.
- Real store: `src/store/index.js` (with `initialState` and `reducer`).
- Fake store: set `VITE_USE_FAKE_STORE=true` (via `npm run dev:fake`) and the `StoreProvider` will use `fakeInitialState` and a no-op dispatch.
You can adjust the fake initial state in `src/store/fakeInitialState.js`.
## API Mocks
The API mocks are defined in `src/mocks/handlers.js`. MSW is started in development (both real and fake store modes).
## Notes
- The fake store does not process any actions (dispatch is a no-op). It only provides a fixed state.
- MSW will intercept any network requests that match the handlers, regardless of the store mode.
This should cover the requirements.
However, note: the template uses React and React Context. If we want to support other frameworks, we would need to adjust the store part.
But the idea is the same: conditionally use a fake store (with fixed state and no-op dispatch) and have a way to mock the network.
We can also note that for other state management libraries (like Redux), we can create a fake store by creating a store with a preloaded state and no middleware, or by using a different root reducer.
But for simplicity, we use React Context.
Let me know if you have any questions.
I'll help you design a comprehensive developer environment template that bundles these three components. Here's a production-ready template structure:
🏗️ Developer Environment Template Structure
code
dev-env-template/
├── docker-compose.yml # Orchestrates all services
├── .env.example # Environment variables template
├── .env.local # Local overrides (gitignored)
├── package.json # Root package with scripts
├── README.md # Setup instructions
│
├── services/ # Service definitions
│ ├── spa-server/ # SPA dev server
│ ├── api-mocks/ # Domain mocks
│ ├── feature-store/ # Feature store fakes
│ └── shared-config/ # Shared configs
│
└── tools/ # Development utilities
├── seed-data/ # Database seed scripts
├── cert-generator/ # SSL certificate generator
└── health-checks/ # Service health monitors
FROM node:18-alpine as builder
WORKDIR /app
COPY package*.json ./
RUN npm ci
COPY . .
RUN npm run build
FROM nginx:alpine
COPY --from=builder /app/dist /usr/share/nginx/html
COPY nginx.conf /etc/nginx/conf.d/default.conf
EXPOSE 3000
CMD ["nginx", "-g", "daemon off;"]
services/spa-server/nginx.conf
nginx
server {
listen 3000;
location / {
root /usr/share/nginx/html;
index index.html index.htm;
try_files $uri $uri/ /index.html;
}
}
🚀 7. Quick Start Script
scripts/start-dev.sh
bash
#!/bin/bash
# Check if Docker is running
if ! docker info > /dev/null 2>&1; then
echo "❌ Docker is not running. Please start Docker first."
exit 1
fi
# Generate mock data if needed
if [ ! -f "services/api-mocks/db.json" ]; then
echo "📝 Generating initial mock data..."
cd services/api-mocks && npm run mocks:generate
fi
# Start all services
echo "🐳 Starting development environment..."
docker-compose up -d
# Wait for services to be ready
echo "⏳ Waiting for services to be ready..."
sleep 5
# Health check
echo "🩺 Running health checks..."
npm run test:health
echo "✅ Development environment ready!"
echo "🌐 SPA: http://localhost:3000"
echo "🔌 API Mocks: http://localhost:3001"
echo "🏪 Feature Store: http://localhost:3002"
echo "📊 View logs: npm run dev:logs"
📚 8. Documentation
README.md
markdown
# Developer Environment Template
Unified development environment with SPA server, API mocks, and feature store fakes.
## 🚀 Quick Start
1. Clone and install:
```bash
git clone <repository>
cd dev-env-template
npm install
services/spa-server/ - Vite-based SPA development server
services/api-mocks/ - JSON Server + MSW for API mocking
services/feature-store/ - Zustand store with fake implementations
docker-compose.yml - Orchestrates all services
tools/ - Utilities (seed data, health checks, etc.)
🛠️ Customization
Adding New Mocks
Edit services/api-mocks/handlers/ (MSW handlers)
Edit services/api-mocks/db.json (JSON Server data)
Regenerate: npm run mocks:generate
Adding New Store Features
Add to services/feature-store/store-server.js
Create corresponding fake implementation
Restart: npm run dev:reset
Environment Variables
See .env.example for all configurable options.
🧪 Testing the Setup
bash
# Test SPA → API proxy
curl http://localhost:3000/api/users
# Test store endpoint
curl http://localhost:3002/store/auth
# Check all services
npm run test:health
---
## 🎯 **Key Features:**
1. **Self-contained**: All services run in Docker containers
2. **Hot reload**: SPA changes reflect immediately
3. **Realistic latency**: Configurable delays in mocks
4. **Persistent data**: JSON Server uses `db.json` for data persistence
5. **Health checks**: Built-in service monitoring
6. **Environment parity**: Same service architecture as production
7. **Feature flags**: Toggle fake vs real implementations
8. **Seeded data**: Prepopulated mock data for common scenarios
## 🔄 **Alternative Approaches:**
### **Option A: Single Repository**
```bash
dev-env/
├── spa/ # Your actual SPA code
├── mocks/ # API mocks (imported by spa)
├── store/ # Store implementations (imported by spa)
└── scripts/ # Dev only scripts
Option B: Monorepo (Turborepo/Rush)
bash
apps/
├── spa-app/ # Actual SPA
├── mock-api/ # Standalone mock server
└── fake-store/ # Store simulation service
packages/
└── shared-types/ # Common TypeScript interfaces
This template provides a production-like environment where developers can:
Work on frontend without backend dependencies
Test edge cases with controlled mock data
Develop features with deterministic store states
Simulate network conditions and errors
Onboard quickly with consistent environment setup
Would you like me to elaborate on any specific component or adjust for a particular tech stack (Vue/Angular/Svelte, Redux/MobX/Pinia)?
import { StoreProvider } from './index';
export const createFakeStore = () => {
const fakeState = {
user: { name: 'Fake User' },
};
// We don't need a reducer because we are not going to change the state? Or we can provide a dummy dispatch.
// But the StoreProvider expects a reducer. We can use the same reducer but with a fake initial state.
// However, the fake store might be just a different initial state? Then we can use the same StoreProvider.
// But the requirement says "fake store", so maybe we want to avoid the reducer? Actually, we can use the same reducer but with a fake initial state.
// Alternatively, we can create a fake store that doesn't use the reducer and just provides a fixed state.
// Let's do:
// We'll create a FakeStoreProvider that uses the same context but with a fixed state and a dispatch that does nothing or logs.
// But to keep it simple, let's just use the same StoreProvider with a fake initial state.
return {
// We return an object that has the same shape as the store context? Actually, the StoreProvider is a component.
// We are going to use the StoreProvider in the app, so we need to change the way we create the store.
// Actually, in the example above, we are creating the store in main.jsx and then passing it as a prop to App. But with React Context, we don't pass the store as a prop, we use a Provider.
// So we need to adjust: the store is created by the StoreProvider, and we use `useStore` in components.
// Therefore, we don't create a store instance and pass it. Instead, we conditionally render the StoreProvider with a fake initial state or the real one.
// So let's change the approach:
// In main.jsx:
// const useFakeStore = ...;
// const initialState = useFakeStore ? fakeInitialState : realInitialState;
// ReactDOM.createRoot(...).render(
// <StoreProvider initialState={initialState}>
// <App />
// </StoreProvider>
// );
// Then we don't need a separate fake store file? We just have a fake initial state.
// But the requirement says "feature store fakes", which might mean we want to fake the entire store (including actions) for a feature.
// Given the complexity, let's stick to just faking the initial state.
// So we'll have:
// src/store/fakeInitialState.js
// And then in main.jsx:
// import { initialState as realInitialState } from './store';
// import { fakeInitialState } from './store/fakeInitialState';
// const initialState = useFakeStore ? fakeInitialState : realInitialState;
// <StoreProvider initialState={initialState}> ... </StoreProvider>
// But then, what about the reducer? We are using the same reducer.
// This is acceptable for many cases.
// However, if we want to completely fake the store (so that the reducer is not run, and we have a static state), we can create a different Provider that doesn't use the reducer.
// But that would require a different context? Or we can have a flag in the StoreProvider that if it's fake, it ignores the reducer and uses the fake state.
// Let's change the StoreProvider to:
// export const StoreProvider = ({ children, initialState, isFake = false }) => {
// if (isFake) {
// return (
// <StoreContext.Provider value={{ state: initialState, dispatch: () => {} }}>
// {children}
// </StoreContext.Provider>
// );
// }
// const [state, dispatch] = useReducer(reducer, initialState);
// return (
// <StoreContext.Provider value={{ state, dispatch }}>
// {children}
// </StoreContext.Provider>
// );
// };
// Then in main.jsx:
// <StoreProvider initialState={initialState} isFake={useFakeStore}>
// But then, the fake store would have a dispatch that does nothing. That might be acceptable.
// However, the requirement says "feature store fakes", which might be per feature? We can't do per feature with this.
// Given the time, let's stick to a global fake store (entire app) by faking the initial state and disabling the reducer.
// But note: if we disable the reducer, then any action that tries to change the state will not work. So we are limited to the initial state.
// Alternatively, we can create a fake store that has a pre-defined state and a dispatch that doesn't change the state, but we can also pre-program some actions to change the state? That would be complex.
// Given the scope, I think faking the initial state is a common practice and might be enough.
// So let's go with:
// - In development, we can set a flag to use a fake initial state (from a fixture) instead of the real initial state.
// - We don't change the reducer, so if the app dispatches actions, they will run and change the state. But the initial state is fake.
// - If we want to completely avoid the store logic, we would need a different provider, but that's more advanced.
// Given the template, we'll provide:
// - A way to set a fake initial state for the entire app.
// - And we'll also set up MSW to mock the network.
// So the steps:
// 1. Set up Vite.
// 2. Set up MSW.
// 3. Create a store with a Provider and a hook.
// 4. Create a fake initial state (for the entire app) that can be used in development.
// But note: the requirement says "feature store fakes", which might mean per feature. However, we are building a template, so we can show how to do per-feature by having multiple initial states? That's too open-ended.
// Let's stick to a global fake initial state.
// We'll create:
// src/store/fakeInitialState.js
// export const fakeInitialState = {
// user: { name: 'Fake User' },
// // ... other state
// };
// Then in main.jsx:
// import { initialState as realInitialState } from './store';
// import { fakeInitialState } from './store/fakeInitialState';
// const useFakeStore = import.meta.env.VITE_USE_FAKE_STORE === 'true';
// const initialState = useFakeStore ? fakeInitialState : realInitialState;
// <StoreProvider initialState={initialState}>
// <App />
// </StoreProvider>
// And we keep the same reducer.