Skip to content

Commit

Permalink
feat: 스크립트로 msw 실행
Browse files Browse the repository at this point in the history
  • Loading branch information
healim01 committed Dec 17, 2024
1 parent cb22f96 commit 7f32f04
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
1 change: 1 addition & 0 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"test": "jest",
"e2e": "playwright test",
"e2e:ui": "playwright test --ui",
"msw": "APP_ENV=msw webpack-dev-server --open --config webpack.dev.js",
"dev": "webpack-dev-server --config webpack.dev.js --open",
"tsc": "tsc --noEmit",
"build": "webpack --mode production --config webpack.prod.js",
Expand Down
6 changes: 3 additions & 3 deletions frontend/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@ Sentry.init({
const root = ReactDOM.createRoot(document.getElementById('root') as HTMLElement);

const enableMocking = async () => {
if (process.env.NODE_ENV !== 'development') {
if (process.env.APP_ENV !== 'msw') {
return;
}

// const { worker } = await import('./mocks/browser');
const { worker } = await import('@/mocks/settings/browser');

// await worker.start();
await worker.start();
};

enableMocking().then(() => {
Expand Down
5 changes: 4 additions & 1 deletion frontend/webpack.dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ const Dotenv = require('dotenv-webpack');

const common = require('./webpack.common.js');

const apiEnv = process.env.APP_ENV || 'development';
const envFilePath = `.env.${apiEnv}`;

module.exports = () => {
return merge(common, {
mode: 'development',
Expand All @@ -14,7 +17,7 @@ module.exports = () => {
plugins: [
new HotModuleReplacementPlugin(),
new Dotenv({
path: './.env.development',
path: `./${envFilePath}`,
}),
],
module: {
Expand Down

0 comments on commit 7f32f04

Please sign in to comment.