webpack settings
This commit is contained in:
15
.gitignore
vendored
15
.gitignore
vendored
@@ -35,3 +35,18 @@ out/
|
||||
|
||||
### VS Code ###
|
||||
.vscode/
|
||||
|
||||
### Node ###
|
||||
/node_modules
|
||||
/build
|
||||
|
||||
dev.js
|
||||
|
||||
|
||||
|
||||
.DS_Store
|
||||
|
||||
npm-debug.log*
|
||||
yarn-debug.kog*
|
||||
yarn-error.log*
|
||||
|
||||
|
||||
67
react_webgame/1. 구구단/gugudan_class.html
Normal file
67
react_webgame/1. 구구단/gugudan_class.html
Normal file
@@ -0,0 +1,67 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8"/>
|
||||
<title>구구단</title>
|
||||
|
||||
<script src="https://unpkg.com/react@16/umd/react.development.js"></script> <!--리액트 핵심 코드-->
|
||||
<script src="https://unpkg.com/react-dom@16/umd/react-dom.development.js"></script> <!-- 리액트 코드를 웹에 붙이는 역할-->
|
||||
<script src="https://unpkg.com/babel-standalone@6/babel.min.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="root"></div>
|
||||
<script type="text/babel">
|
||||
class GuGuDan extends React.Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.state = {
|
||||
first: Math.ceil(Math.random() * 9),
|
||||
second: Math.ceil(Math.random() * 9),
|
||||
value: '',
|
||||
result: '',
|
||||
};
|
||||
}
|
||||
|
||||
onSubmit = (e) => {
|
||||
e.preventDefault();
|
||||
if(parseInt(this.state.value) === this.state.first * this.state.second) {
|
||||
this.setState((prevState) => {
|
||||
return {
|
||||
result: '정답 : ' + prevState.value,
|
||||
first: Math.ceil(Math.random() * 9),
|
||||
second: Math.ceil(Math.random() * 9),
|
||||
value: '',
|
||||
}
|
||||
});
|
||||
this.input.focus();
|
||||
} else {
|
||||
this.setState({
|
||||
result: '땡',
|
||||
value: '',
|
||||
});
|
||||
this.input.focus();
|
||||
}
|
||||
}
|
||||
|
||||
onChange = (e) => this.setState({ value: e.target.value});
|
||||
|
||||
onRefInput = (c) => { this.input = c; };
|
||||
|
||||
render() {
|
||||
return (
|
||||
<React.Fragment>
|
||||
<div>{this.state.first} 곱하기 {this.state.second} 는?</div>
|
||||
<form onSubmit={this.onSubmit}>
|
||||
<input ref={this.onRefInput} type="number" value={this.state.value} onChange={this.onChange}/>
|
||||
<button>입력!</button>
|
||||
</form>
|
||||
<div>{this.state.result}</div>
|
||||
</React.Fragment>
|
||||
);
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<script type="text/babel">
|
||||
ReactDOM.render(<GuGuDan/>, document.querySelector('#root'));
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
116
react_webgame/main/.gitignore
vendored
Normal file
116
react_webgame/main/.gitignore
vendored
Normal file
@@ -0,0 +1,116 @@
|
||||
|
||||
# Created by https://www.toptal.com/developers/gitignore/api/node
|
||||
# Edit at https://www.toptal.com/developers/gitignore?templates=node
|
||||
|
||||
### Node ###
|
||||
# Logs
|
||||
logs
|
||||
*.log
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
lerna-debug.log*
|
||||
|
||||
# Diagnostic reports (https://nodejs.org/api/report.html)
|
||||
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
|
||||
|
||||
# Runtime data
|
||||
pids
|
||||
*.pid
|
||||
*.seed
|
||||
*.pid.lock
|
||||
|
||||
# Directory for instrumented libs generated by jscoverage/JSCover
|
||||
lib-cov
|
||||
|
||||
# Coverage directory used by tools like istanbul
|
||||
coverage
|
||||
*.lcov
|
||||
|
||||
# nyc test coverage
|
||||
.nyc_output
|
||||
|
||||
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
|
||||
.grunt
|
||||
|
||||
# Bower dependency directory (https://bower.io/)
|
||||
bower_components
|
||||
|
||||
# node-waf configuration
|
||||
.lock-wscript
|
||||
|
||||
# Compiled binary addons (https://nodejs.org/api/addons.html)
|
||||
build/Release
|
||||
|
||||
# Dependency directories
|
||||
node_modules/
|
||||
jspm_packages/
|
||||
|
||||
# TypeScript v1 declaration files
|
||||
typings/
|
||||
|
||||
# TypeScript cache
|
||||
*.tsbuildinfo
|
||||
|
||||
# Optional npm cache directory
|
||||
.npm
|
||||
|
||||
# Optional eslint cache
|
||||
.eslintcache
|
||||
|
||||
# Microbundle cache
|
||||
.rpt2_cache/
|
||||
.rts2_cache_cjs/
|
||||
.rts2_cache_es/
|
||||
.rts2_cache_umd/
|
||||
|
||||
# Optional REPL history
|
||||
.node_repl_history
|
||||
|
||||
# Output of 'npm pack'
|
||||
*.tgz
|
||||
|
||||
# Yarn Integrity file
|
||||
.yarn-integrity
|
||||
|
||||
# dotenv environment variables file
|
||||
.env
|
||||
.env.test
|
||||
.env*.local
|
||||
|
||||
# parcel-bundler cache (https://parceljs.org/)
|
||||
.cache
|
||||
.parcel-cache
|
||||
|
||||
# Next.js build output
|
||||
.next
|
||||
|
||||
# Nuxt.js build / generate output
|
||||
.nuxt
|
||||
dist
|
||||
|
||||
# Gatsby files
|
||||
.cache/
|
||||
# Comment in the public line in if your project uses Gatsby and not Next.js
|
||||
# https://nextjs.org/blog/next-9-1#public-directory-support
|
||||
# public
|
||||
|
||||
# vuepress build output
|
||||
.vuepress/dist
|
||||
|
||||
# Serverless directories
|
||||
.serverless/
|
||||
|
||||
# FuseBox cache
|
||||
.fusebox/
|
||||
|
||||
# DynamoDB Local files
|
||||
.dynamodb/
|
||||
|
||||
# TernJS port file
|
||||
.tern-port
|
||||
|
||||
# Stores VSCode versions used for testing VSCode extensions
|
||||
.vscode-test
|
||||
|
||||
# End of https://www.toptal.com/developers/gitignore/api/node
|
||||
16
react_webgame/main/WordRelay.jsx
Normal file
16
react_webgame/main/WordRelay.jsx
Normal file
@@ -0,0 +1,16 @@
|
||||
const React = require('react');
|
||||
const { Component } = React;
|
||||
|
||||
class WordRelay extends Component {
|
||||
state = {
|
||||
text: 'Hello, webpack',
|
||||
};
|
||||
|
||||
render() {
|
||||
return (
|
||||
<h1>{this.state.text}</h1>
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = WordRelay;
|
||||
6
react_webgame/main/client.jsx
Normal file
6
react_webgame/main/client.jsx
Normal file
@@ -0,0 +1,6 @@
|
||||
const React = require('react');
|
||||
const ReactDom = require('react-dom');
|
||||
|
||||
const WordRelay = require('./WordRelay');
|
||||
|
||||
ReactDom.render(<WordRelay />, document.querySelector('#root'));
|
||||
@@ -1,67 +1,10 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8"/>
|
||||
<title>구구단</title>
|
||||
|
||||
<script src="https://unpkg.com/react@16/umd/react.development.js"></script> <!--리액트 핵심 코드-->
|
||||
<script src="https://unpkg.com/react-dom@16/umd/react-dom.development.js"></script> <!-- 리액트 코드를 웹에 붙이는 역할-->
|
||||
<script src="https://unpkg.com/babel-standalone@6/babel.min.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="root"></div>
|
||||
<script type="text/babel">
|
||||
class GuGuDan extends React.Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.state = {
|
||||
first: Math.ceil(Math.random() * 9),
|
||||
second: Math.ceil(Math.random() * 9),
|
||||
value: '',
|
||||
result: '',
|
||||
};
|
||||
}
|
||||
|
||||
onSubmit = (e) => {
|
||||
e.preventDefault();
|
||||
if(parseInt(this.state.value) === this.state.first * this.state.second) {
|
||||
this.setState((prevState) => {
|
||||
return {
|
||||
result: '정답 : ' + prevState.value,
|
||||
first: Math.ceil(Math.random() * 9),
|
||||
second: Math.ceil(Math.random() * 9),
|
||||
value: '',
|
||||
}
|
||||
});
|
||||
this.input.focus();
|
||||
} else {
|
||||
this.setState({
|
||||
result: '땡',
|
||||
value: '',
|
||||
});
|
||||
this.input.focus();
|
||||
}
|
||||
}
|
||||
|
||||
onChange = (e) => this.setState({ value: e.target.value});
|
||||
|
||||
onRefInput = (c) => { this.input = c; };
|
||||
|
||||
render() {
|
||||
return (
|
||||
<React.Fragment>
|
||||
<div>{this.state.first} 곱하기 {this.state.second} 는?</div>
|
||||
<form onSubmit={this.onSubmit}>
|
||||
<input ref={this.onRefInput} type="number" value={this.state.value} onChange={this.onChange}/>
|
||||
<button>입력!</button>
|
||||
</form>
|
||||
<div>{this.state.result}</div>
|
||||
</React.Fragment>
|
||||
);
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<script type="text/babel">
|
||||
ReactDOM.render(<GuGuDan/>, document.querySelector('#root'));
|
||||
</script>
|
||||
</body>
|
||||
<head>
|
||||
<meta charset="utf-8"/>
|
||||
<title>끝말잇기</title>
|
||||
</head>
|
||||
<body>
|
||||
<div id="root"></div>
|
||||
<script src="./dist/app.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
2729
react_webgame/main/package-lock.json
generated
Normal file
2729
react_webgame/main/package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
25
react_webgame/main/package.json
Normal file
25
react_webgame/main/package.json
Normal file
@@ -0,0 +1,25 @@
|
||||
{
|
||||
"name": "main",
|
||||
"version": "1.0.0",
|
||||
"description": "",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"dev": "webpack",
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"author": "kim",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"react": "^17.0.1",
|
||||
"react-dom": "^17.0.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.12.10",
|
||||
"@babel/plugin-proposal-class-properties": "^7.12.1",
|
||||
"@babel/preset-env": "^7.12.11",
|
||||
"@babel/preset-react": "^7.12.10",
|
||||
"babel-loader": "^8.2.2",
|
||||
"webpack": "^5.11.0",
|
||||
"webpack-cli": "^4.2.0"
|
||||
}
|
||||
}
|
||||
30
react_webgame/main/webpack.config.js
Normal file
30
react_webgame/main/webpack.config.js
Normal file
@@ -0,0 +1,30 @@
|
||||
const path = require('path'); // 경로 조작하는 모듈
|
||||
|
||||
module.exports = {
|
||||
name: 'wordrelay-setting',
|
||||
mode: 'development', // 실 서비스 에서는 production
|
||||
devtool: 'eval',
|
||||
resolve: {
|
||||
extensions: ['.js', '.jsx']
|
||||
},
|
||||
|
||||
entry: {
|
||||
app:['./client'],
|
||||
}, // 입력
|
||||
|
||||
module: {
|
||||
rules: [{
|
||||
test: /\.jsx?/, // js, jsx 파일에 babel-loader적용
|
||||
loader: 'babel-loader',
|
||||
options: {
|
||||
presets: ['@babel/preset-env', '@babel/preset-react'],
|
||||
plugins: ['@babel/plugin-proposal-class-properties'],
|
||||
},
|
||||
}],
|
||||
}, // 모듈적용
|
||||
|
||||
output: {
|
||||
path: path.join(__dirname, 'dist'),
|
||||
filename: 'app.js'
|
||||
} // 출력
|
||||
};
|
||||
Reference in New Issue
Block a user