23 lines
1.2 KiB
JavaScript

import { configureStore } from '@reduxjs/toolkit';
import authReducer from '../features/auth/authSlice';
export const store = configureStore({
reducer: {
// กำหนด Reducer หลัก
auth: authReducer,
// [เพิ่ม Reducer อื่น ๆ ที่นี่]
},
// ปิด serializableCheck ใน Production เพื่อประสิทธิภาพ
middleware: (getDefaultMiddleware) => getDefaultMiddleware({
serializableCheck: {
// อาจจะต้องยกเว้น action types บางตัวที่ไม่ serialize ได้
},
}),
// ใน Vite ตัวแปร import.meta.env.MODE จะถูก ตั้งค่าให้อัตโนมัติ ตามคำสั่งที่ใช้ตอนรัน เช่น
// vite หรือ npm run dev "development"
// vite build หรือ npm run build "production"
devTools: import.meta.env.MODE !== 'production',
});
// Export ฟังก์ชันเพื่อให้ Components ภายนอก (เช่น axiosClient) เข้าถึง store instance ได้
export const getStore = () => store;