inflearn logo
강의

강의

N
챌린지

챌린지

멘토링

멘토링

N
클립

클립

로드맵

로드맵

지식공유

웹 게임을 만들며 배우는 React

3-6. 숫자야구 만들기

dist 폴더 생성 문의

681

아침에사과

작성한 질문수 21

0

이 설정의 경우도 dist 폴더가 생성되어야 하는게 맞는건가요? 

const path = require('path');
const RefreshWebpackPlugin = require('@pmmmwh/react-refresh-webpack-plugin')

module.exports = {
name: 'numberbaseball-setting',
mode: 'development', // 실서비스: production
devtool: 'eval', // 실서비스: hidden-source-map
resolve: {
extensions: ['.js', '.jsx']
},

entry: {
// 입력
app: ['./client'],
},

module: {
rules: [{

test: /\.jsx?$/,
loader: 'babel-loader',
options: {
presets: [
['@babel/preset-env', {
targets: {
browsers: ['> 5% in KR'], // browserslist
},
debug: true,
}],
'@babel/preset-react',
],
plugins: [
'@babel/plugin-proposal-class-properties',
'react-refresh/babel',
],
},
}],
},
plugins: [
new RefreshWebpackPlugin()
],
// 출력
output: {
// 실제 경로
path: path.join(__dirname, 'dist'),
filename: 'app.js',
publicPath: '/dist/', // app.use('/dist', express.static(__dirname, 'dist')
},
devServer: {
publicPath: '/dist/',
hot: true,
},
};
{
"name": "numberbaseball",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"dev": "webpack serve --env development"
},
"author": "",
"license": "MIT",
"dependencies": {
"react": "^17.0.1",
"react-dom": "^17.0.1"
},
"devDependencies": {
"@babel/core": "^7.12.16",
"@babel/plugin-proposal-class-properties": "^7.12.13",
"@babel/preset-env": "^7.12.16",
"@babel/preset-react": "^7.12.13",
"@pmmmwh/react-refresh-webpack-plugin": "^0.4.3",
"babel-loader": "^8.2.2",
"react-refresh": "^0.9.0",
"webpack": "^5.22.0",
"webpack-cli": "^4.5.0",
"webpack-dev-server": "^3.11.2"
}
}

제 경우는 위와 같은 설정에서 dist 폴더가 생성이 안되어서 아래와 같이 조치를 했지만 다음과 같은 에러가 발생합니다.

webpack.config.js 상단에

const webpack = require('webpack');

를 추가해주고 

plugins: [
new RefreshWebpackPlugin(),
new webpack.LoaderOptionsPlugin({ debug: true }),
],

package.json에 

"scripts": {
"dev": "webpack serve --env development",
"webpack": "webpack"
},

를 추가해줘서 npm run webpack을 실행해보았는데요.

다음과 같은 에러가 발생해서 문의 남겨봅니다.

(npm run dev에는 문제가 없습니다.)

[Browserslist] Could not parse C:\Users\프로젝트\react-webgame\package.json. Ignoring it.

internal/crypto/hash.js:58

    throw new ERR_INVALID_ARG_TYPE('data',

    ^

TypeError [ERR_INVALID_ARG_TYPE]: The "data" argument must be one of type string, TypedArray, or DataView. Received type undefined

    at Hash.update (internal/crypto/hash.js:58:11)

    at BulkUpdateDecorator.update (C:\Users\프로젝트\react-webgame\숫자야구\node_modules\webpack\lib\util\createHash.js:51:14)

    at NormalModule.updateHash (C:\Users\프로젝트\react-webgame\숫자야구\node_modules\webpack\lib\NormalModule.js:1129:8)

    at Compilation._createModuleHash (C:\Users\프로젝트\react-webgame\숫자야구\node_modules\webpack\lib\Compilation.js:3085:10)

    at Compilation.createModuleHashes (C:\Users\프로젝트\react-webgame\숫자야구\node_modules\webpack\lib\Compilation.js:3057:10)

    at hooks.optimizeChunkModules.callAsync.err (C:\Users\프로젝트\react-webgame\숫자야구\node_modules\webpack\lib\Compilation.js:2334:11)

    at Hook.eval [as callAsync] (eval at create (C:\Users\프로젝트\react-webgame\숫자야구\node_modules\tapable\lib\HookCodeFactory.js:33:10), <anonymous>:6:1)

    at Hook.CALL_ASYNC_DELEGATE [as _callAsync] (C:\Users\프로젝트\react-webgame\숫자야구\node_modules\tapable\lib\Hook.js:18:14)

    at hooks.optimizeTree.callAsync.err (C:\Users\프로젝트\react-webgame\숫자야구\node_modules\webpack\lib\Compilation.js:2294:36)

    at Hook.eval [as callAsync] (eval at create (C:\Users\프로젝트\react-webgame\숫자야구\node_modules\tapable\lib\HookCodeFactory.js:33:10), <anonymous>:6:1)

npm ERR! code 1

npm ERR! path C:\Users\프로젝트\react-webgame\숫자야구

npm ERR! command failed

npm ERR! command C:\WINDOWS\system32\cmd.exe /d /s /c webpack

npm ERR! A complete log of this run can be found in:

npm ERR!     C:\Users\rlawj\AppData\Local\npm-cache\_logs\2021-02-21T06_35_11_452Z-debug.log

[Browserslist] Could not parse ~~ 부분은 신경 안써줘도 되는지도 궁금합니다.

presets: [
['@babel/preset-env', {
targets: {
browsers: ['> 1% in KR'], // browserslist
},
debug: true,
}],
'@babel/preset-react',
],

react

답변 0

npm run dev 실행 시 포트가 안뜨는 문제

0

202

2

timeouts.current를 useEffect 의 input값으로 넣었을때

0

85

2

렌더링 테스트 코드 (Hooks)

0

80

1

Cannot find package 'react-refesh' 이런 에러 뜨시는 분들 보세요.

0

149

1

해당 에러 뜨는 분들 보세요. "Uncaught TypeError: ReactDom.createRoot is not a function"

1

191

1

강사님 레포지토리에서 코드 복사 시 master 브랜치 말고 react18 브랜치꺼 복붙하세요ㅠㅠ

0

95

1

useMemo와 useCallback 사용 시기

0

205

2

onRightClickTd가 작동을 하지 않습니다.

0

226

1

action.type 불러오는 방식

0

222

2

onClickRedo 질문

0

172

1

const Try = require(./Try) 빨간줄

0

248

1

npx webpack 실행시

0

313

1

지뢰찾기 강좌에서 빈칸들 한번에 열기 파트에서 여쭤보고싶은부분이 있어서 글 올립니다.

0

234

1

강좌에서 다루지 않은 기능들은 어떻게 학습하면 좋을까요?

0

311

1

react devtool이 enable 않됩니다.

0

530

2

React 랜더링이 되지 않습니다.

0

409

2

비동기로 동작하는 setState에 대해서

0

331

1

npm run dev 할 때 에러발생

0

478

2

memo, PureComponenet, shouldComponentUpdate 관련 질문

0

206

1

devMiddleware의 필요성

0

352

1

리액트에서 화살표 함수를 사용해야하는 이유

0

932

2

path.join관련질문

0

280

2

2-9. 웹팩 데브 서버와 핫 리로딩 설치과정 시 에러

0

372

1

next.js 에서 이와 비슷한 예제를 돌리고있는데 react랑 달라서 질문 드립니

1

489

4