Initial commit
This commit is contained in:
3
.env.example
Normal file
3
.env.example
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
PROTOCOL=http
|
||||||
|
HOSTNAME=localhost
|
||||||
|
PORT=8000
|
||||||
17
.eslintrc
Normal file
17
.eslintrc
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
{
|
||||||
|
"extends": [
|
||||||
|
"eslint:recommended",
|
||||||
|
"plugin:prettier/recommended",
|
||||||
|
"plugin:@typescript-eslint/eslint-recommended",
|
||||||
|
"plugin:@typescript-eslint/recommended",
|
||||||
|
"plugin:import/errors",
|
||||||
|
"plugin:import/warnings",
|
||||||
|
"plugin:import/typescript"
|
||||||
|
],
|
||||||
|
"plugins": [ "@typescript-eslint"],
|
||||||
|
"parser": "@typescript-eslint/parser",
|
||||||
|
"env": {
|
||||||
|
"node": true
|
||||||
|
},
|
||||||
|
"root": true
|
||||||
|
}
|
||||||
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
node_modules
|
||||||
|
.env
|
||||||
11
.prettierrc.json
Normal file
11
.prettierrc.json
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"trailingComma": "es5",
|
||||||
|
"tabWidth": 2,
|
||||||
|
"semi": true,
|
||||||
|
"singleQuote": false,
|
||||||
|
"jsxSingleQuote": false,
|
||||||
|
"jsxBracketSameLine": false,
|
||||||
|
"arrowParens": "avoid",
|
||||||
|
"useTabs": false,
|
||||||
|
"bracketSpacing": true
|
||||||
|
}
|
||||||
41
client/.eslintrc
Normal file
41
client/.eslintrc
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
{
|
||||||
|
"env": {
|
||||||
|
"browser": true,
|
||||||
|
"es2020": true
|
||||||
|
},
|
||||||
|
"extends": [
|
||||||
|
"plugin:react/recommended"
|
||||||
|
],
|
||||||
|
"parser": "@typescript-eslint/parser",
|
||||||
|
"parserOptions": {
|
||||||
|
"ecmaFeatures": {
|
||||||
|
"jsx": true
|
||||||
|
},
|
||||||
|
"ecmaVersion": 11,
|
||||||
|
"sourceType": "module"
|
||||||
|
},
|
||||||
|
"plugins": ["react"],
|
||||||
|
"rules": {},
|
||||||
|
"settings": {
|
||||||
|
"react": {
|
||||||
|
"version": "detect"
|
||||||
|
},
|
||||||
|
"import/resolver": {
|
||||||
|
"node": {
|
||||||
|
"paths": ["client"],
|
||||||
|
"extensions": [".js", ".jsx", ".ts", ".tsx"]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"overrides": [
|
||||||
|
{
|
||||||
|
"files": [
|
||||||
|
"**/*.tsx"
|
||||||
|
],
|
||||||
|
"rules": {
|
||||||
|
"react/react-in-jsx-scope": "off",
|
||||||
|
"react/prop-types": "off"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
5
client/App.tsx
Normal file
5
client/App.tsx
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
import React from "react";
|
||||||
|
|
||||||
|
export default function App(): JSX.Element {
|
||||||
|
return <div>Hello World!</div>;
|
||||||
|
}
|
||||||
16
client/index.hbs
Normal file
16
client/index.hbs
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="ko">
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" />
|
||||||
|
<meta name="description" content="tf-ocr" />
|
||||||
|
<title>동애니</title>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<noscript>You need to enable JavaScript to run this app.</noscript>
|
||||||
|
<div id="root"></div>
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
||||||
5
client/index.tsx
Normal file
5
client/index.tsx
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
import ReactDOM from "react-dom";
|
||||||
|
import App from "App";
|
||||||
|
import React from "react";
|
||||||
|
|
||||||
|
ReactDOM.render(<App />, document.getElementById("root"));
|
||||||
14
client/tsconfig.json
Normal file
14
client/tsconfig.json
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"outDir": "../dist/client",
|
||||||
|
"noImplicitAny": true,
|
||||||
|
"module": "es6",
|
||||||
|
"target": "es5",
|
||||||
|
"jsx": "react",
|
||||||
|
"allowJs": true,
|
||||||
|
"sourceMap": true,
|
||||||
|
"moduleResolution": "node",
|
||||||
|
"allowSyntheticDefaultImports": true,
|
||||||
|
"baseUrl": "./"
|
||||||
|
},
|
||||||
|
}
|
||||||
55
package.json
Normal file
55
package.json
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
{
|
||||||
|
"name": "dongani",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"main": "index.js",
|
||||||
|
"repository": "https://git.alien.moe/vbalien/dongani.git",
|
||||||
|
"author": "Jisu Kim <webmaster@alien.moe>",
|
||||||
|
"license": "MIT",
|
||||||
|
"scripts": {
|
||||||
|
"build": "cross-env NODE_ENV=\"production\" TS_NODE_PROJECT=\"tsconfig-for-webpack-config.json\" webpack --config webpack.config.ts",
|
||||||
|
"start:dev": "cross-env NODE_ENV=\"development\" TS_NODE_PROJECT=\"server/tsconfig.json\" ts-node server/index.ts",
|
||||||
|
"start:prod": "yarn build && tsc -b server && node dist/server/index.js",
|
||||||
|
"lint": "eslint . --ext .ts,.tsx,.js,.jsx"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"@types/react-dom": "^17.0.0",
|
||||||
|
"apollo-server-koa": "^2.19.1",
|
||||||
|
"koa-static": "^5.0.0",
|
||||||
|
"koa-webpack": "^6.0.0",
|
||||||
|
"react": "^17.0.1",
|
||||||
|
"react-dom": "^17.0.1"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@babel/core": "^7.12.10",
|
||||||
|
"@babel/plugin-proposal-class-properties": "^7.12.1",
|
||||||
|
"@babel/plugin-proposal-decorators": "^7.12.12",
|
||||||
|
"@babel/preset-env": "^7.12.11",
|
||||||
|
"@babel/preset-react": "^7.12.10",
|
||||||
|
"@babel/preset-typescript": "^7.12.7",
|
||||||
|
"@pmmmwh/react-refresh-webpack-plugin": "^0.4.3",
|
||||||
|
"@types/webpack-dev-server": "^3.11.1",
|
||||||
|
"@typescript-eslint/eslint-plugin": "^4.12.0",
|
||||||
|
"@typescript-eslint/parser": "^4.12.0",
|
||||||
|
"babel-loader": "^8.2.2",
|
||||||
|
"cross-env": "^7.0.3",
|
||||||
|
"css-loader": "^5.0.1",
|
||||||
|
"dotenv-webpack": "^6.0.0",
|
||||||
|
"eslint": "^7.17.0",
|
||||||
|
"eslint-config-prettier": "^7.1.0",
|
||||||
|
"eslint-plugin-import": "^2.22.1",
|
||||||
|
"eslint-plugin-prettier": "^3.3.1",
|
||||||
|
"eslint-plugin-react": "^7.22.0",
|
||||||
|
"fork-ts-checker-webpack-plugin": "^6.0.8",
|
||||||
|
"handlebars": "^4.7.6",
|
||||||
|
"handlebars-loader": "^1.7.1",
|
||||||
|
"html-webpack-plugin": "^4.5.1",
|
||||||
|
"prettier": "^2.2.1",
|
||||||
|
"react-refresh": "^0.9.0",
|
||||||
|
"style-loader": "^2.0.0",
|
||||||
|
"ts-node": "^9.1.1",
|
||||||
|
"typescript": "^4.1.3",
|
||||||
|
"webpack": "^4.44.2",
|
||||||
|
"webpack-cli": "^4.3.1",
|
||||||
|
"webpack-dev-server": "^3.11.1"
|
||||||
|
}
|
||||||
|
}
|
||||||
10
server/.eslintrc
Normal file
10
server/.eslintrc
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
{
|
||||||
|
"settings": {
|
||||||
|
"import/resolver": {
|
||||||
|
"node": {
|
||||||
|
"paths": ["server"],
|
||||||
|
"extensions": [".js", ".ts"]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
24
server/index.ts
Normal file
24
server/index.ts
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
import Koa from "koa";
|
||||||
|
import serve from "koa-static";
|
||||||
|
import path from "path";
|
||||||
|
import dotenv from "dotenv";
|
||||||
|
|
||||||
|
dotenv.config();
|
||||||
|
(async () => {
|
||||||
|
const app = new Koa();
|
||||||
|
if (process.env.NODE_ENV === "development") {
|
||||||
|
const koaWebpack = (await import("koa-webpack")).default;
|
||||||
|
const config = (await import("../webpack.config")).default;
|
||||||
|
const middleware = await koaWebpack({
|
||||||
|
config,
|
||||||
|
devMiddleware: { publicPath: "/" },
|
||||||
|
});
|
||||||
|
app.use(middleware);
|
||||||
|
} else {
|
||||||
|
app.use(serve(path.resolve(__dirname, "../client")));
|
||||||
|
}
|
||||||
|
console.info(
|
||||||
|
`Server listening on ${process.env.PROTOCOL}://${process.env.HOSTNAME}:${process.env.PORT}`
|
||||||
|
);
|
||||||
|
app.listen(Number.parseInt(process.env.PORT), process.env.HOSTNAME);
|
||||||
|
})().catch(err => console.log(err));
|
||||||
16
server/tsconfig.json
Normal file
16
server/tsconfig.json
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"outDir": "../dist",
|
||||||
|
"lib": [
|
||||||
|
"es5",
|
||||||
|
"es6"
|
||||||
|
],
|
||||||
|
"target": "es6",
|
||||||
|
"module": "commonjs",
|
||||||
|
"moduleResolution": "node",
|
||||||
|
"emitDecoratorMetadata": true,
|
||||||
|
"experimentalDecorators": true,
|
||||||
|
"esModuleInterop": true,
|
||||||
|
"sourceMap": true,
|
||||||
|
},
|
||||||
|
}
|
||||||
7
tsconfig.webpack.json
Normal file
7
tsconfig.webpack.json
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"module": "commonjs",
|
||||||
|
"target": "es5",
|
||||||
|
"esModuleInterop": true
|
||||||
|
}
|
||||||
|
}
|
||||||
84
webpack.config.ts
Normal file
84
webpack.config.ts
Normal file
@@ -0,0 +1,84 @@
|
|||||||
|
import * as path from "path";
|
||||||
|
import ForkTsCheckerWebpackPlugin from "fork-ts-checker-webpack-plugin";
|
||||||
|
import ReactRefreshWebpackPlugin from "@pmmmwh/react-refresh-webpack-plugin";
|
||||||
|
import HtmlWebpackPlugin from "html-webpack-plugin";
|
||||||
|
import webpack from "webpack";
|
||||||
|
import Dotenv from "dotenv-webpack";
|
||||||
|
|
||||||
|
const isDevelopment = process.env.NODE_ENV !== "production";
|
||||||
|
|
||||||
|
const config: webpack.Configuration = {
|
||||||
|
mode: isDevelopment ? "development" : "production",
|
||||||
|
entry: "./client/index.tsx",
|
||||||
|
output: {
|
||||||
|
filename: "bundle.js",
|
||||||
|
path: path.resolve(__dirname, "dist/client"),
|
||||||
|
},
|
||||||
|
resolve: {
|
||||||
|
extensions: [".tsx", ".ts", ".js", ".mjs"],
|
||||||
|
modules: [path.join(__dirname, "./client"), "node_modules"],
|
||||||
|
},
|
||||||
|
module: {
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
test: /\.css$/i,
|
||||||
|
use: ["style-loader", "css-loader"],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
test: /\.hbs$/,
|
||||||
|
loader: "handlebars-loader",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
test: /\.(mjs|js|jsx|ts|tsx)$/,
|
||||||
|
exclude: /node_modules/,
|
||||||
|
use: {
|
||||||
|
loader: "babel-loader",
|
||||||
|
options: {
|
||||||
|
cacheDirectory: true,
|
||||||
|
babelrc: false,
|
||||||
|
presets: [
|
||||||
|
[
|
||||||
|
"@babel/preset-env",
|
||||||
|
{
|
||||||
|
targets: { browsers: "last 2 versions" },
|
||||||
|
useBuiltIns: "usage",
|
||||||
|
corejs: 3,
|
||||||
|
}, // or whatever your project requires
|
||||||
|
],
|
||||||
|
["@babel/preset-typescript", { onlyRemoveTypeImports: true }],
|
||||||
|
"@babel/preset-react",
|
||||||
|
],
|
||||||
|
plugins: [
|
||||||
|
// plugin-proposal-decorators is only needed if you're using experimental decorators in TypeScript
|
||||||
|
["@babel/plugin-proposal-decorators", { legacy: true }],
|
||||||
|
["@babel/plugin-proposal-class-properties", { loose: true }],
|
||||||
|
isDevelopment && require.resolve("react-refresh/babel"),
|
||||||
|
].filter(Boolean),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
plugins: [
|
||||||
|
new Dotenv(),
|
||||||
|
new ForkTsCheckerWebpackPlugin({
|
||||||
|
async: false,
|
||||||
|
eslint: {
|
||||||
|
files: "./client/**/*.{ts,tsx,js,jsx}",
|
||||||
|
},
|
||||||
|
typescript: { configFile: "client/tsconfig.json" },
|
||||||
|
}),
|
||||||
|
new HtmlWebpackPlugin({
|
||||||
|
template: "client/index.hbs",
|
||||||
|
}),
|
||||||
|
isDevelopment && new ReactRefreshWebpackPlugin(),
|
||||||
|
].filter(Boolean),
|
||||||
|
devServer: {
|
||||||
|
hot: true,
|
||||||
|
contentBase: "./dist/client",
|
||||||
|
overlay: true,
|
||||||
|
},
|
||||||
|
devtool: isDevelopment ? "inline-source-map" : undefined,
|
||||||
|
};
|
||||||
|
|
||||||
|
export default config;
|
||||||
6631
yarn-error.log
Normal file
6631
yarn-error.log
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user