Skip to content

Commit 802e97d

Browse files
committed
base react structure
1 parent cc7f008 commit 802e97d

9 files changed

+3888
-0
lines changed

.editorconfig

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# This file is for unifying the coding style for different editors and IDEs
2+
# editorconfig.org
3+
root = true
4+
5+
[*]
6+
end_of_line = lf
7+
charset = utf-8
8+
trim_trailing_whitespace = true
9+
insert_final_newline = true
10+
indent_style = space
11+
indent_size = 2
12+
13+
[*.md]
14+
trim_trailing_whitespace = false
15+
16+
[{Makefile, **.mk}]
17+
indent_style = tab

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
.idea
2+
node_modules

package.json

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"name": "outliner",
3+
"version": "0.0.1",
4+
"main": "index.js",
5+
"repository": "git@github.com:Yixi/outliner.git",
6+
"author": "Yixi <lyh1112@gmail.com>",
7+
"dependencies": {
8+
"react": "^16.6.0",
9+
"react-dom": "^16.6.0"
10+
},
11+
"scripts": {
12+
"dev": "yarn start",
13+
"start": "webpack-dev-server --open --config webpack/webpack.dev.config.js --progress"
14+
},
15+
"devDependencies": {
16+
"@types/react": "^16.4.18",
17+
"@types/react-dom": "^16.0.9",
18+
"fork-ts-checker-webpack-plugin": "^0.4.12",
19+
"html-webpack-plugin": "^3.2.0",
20+
"source-map-loader": "^0.2.4",
21+
"ts-loader": "^5.2.2",
22+
"tslint": "^5.11.0",
23+
"tslint-react": "^3.6.0",
24+
"typescript": "^3.1.3",
25+
"webpack": "^4.23.1",
26+
"webpack-cli": "^3.1.2",
27+
"webpack-dev-server": "^3.1.10"
28+
}
29+
}

src/app.html

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<!doctype html>
2+
<html>
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta name="viewport"
6+
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
7+
<meta http-equiv="X-UA-Compatible" content="ie=edge">
8+
<title>Outliner</title>
9+
</head>
10+
<body>
11+
<div id="MainApp"></div>
12+
</body>
13+
</html>

src/index.tsx

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import * as React from 'react'
2+
import * as ReactDOM from 'react-dom'
3+
4+
const mountNode = document.getElementById('MainApp')
5+
6+
ReactDOM.render(<div>outliner</div>, mountNode)

tsconfig.json

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"compilerOptions": {
3+
"baseUrl": ".",
4+
"paths": {
5+
"@root/*": [
6+
"src/*"
7+
]
8+
},
9+
"lib": [
10+
"es6",
11+
"es7",
12+
"dom"
13+
],
14+
"outDir": "./dist/",
15+
"sourceMap": true,
16+
"noImplicitAny": true,
17+
"target": "es5",
18+
"jsx": "react",
19+
"allowJs": true,
20+
"experimentalDecorators": true,
21+
"allowSyntheticDefaultImports": true
22+
},
23+
"include": [
24+
"src/**/*"
25+
]
26+
}

tslint.json

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"extends": ["tslint:recommended", "tslint-react"],
3+
"rules": {
4+
"jsx-no-multiline-js": false,
5+
"jsx-alignment": false,
6+
"semicolon": [
7+
true,
8+
"never"
9+
],
10+
"quotemark": [
11+
true,
12+
"single",
13+
"jsx-double",
14+
"avoid-escape"
15+
],
16+
"ordered-imports": [
17+
false
18+
],
19+
"jsx-boolean-value": [
20+
false
21+
],
22+
"member-access": [true, "no-public"],
23+
"no-var-requires": false,
24+
"no-console": false,
25+
"object-literal-sort-keys": false,
26+
"whitespace": [true, "check-module"]
27+
}
28+
}

webpack/webpack.dev.config.js

+73
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
const path = require('path')
2+
const webpack = require('webpack')
3+
const HtmlWebpackPlugin = require('html-webpack-plugin')
4+
const ForkTsCheckerWebpackPlugin = require("fork-ts-checker-webpack-plugin")
5+
6+
const PORT = 4222;
7+
const HOST = 'http://localhost';
8+
const URL = `${HOST}:${PORT}`;
9+
10+
module.exports = {
11+
mode: 'development',
12+
entry: [
13+
'../src/index.tsx'
14+
],
15+
output: {
16+
filename: 'app.js',
17+
path: path.join(__dirname, '../dist'),
18+
publicPath: ''
19+
},
20+
context: path.resolve(__dirname, '../src'),
21+
devtool: 'source-map',
22+
devServer: {
23+
stats: {
24+
cached: true,
25+
chunkModules: false,
26+
colors: true
27+
},
28+
hot: true,
29+
compress: true,
30+
contentBase: path.resolve(__dirname, '../src'),
31+
port: PORT,
32+
publicPath: URL,
33+
historyApiFallback: true,
34+
},
35+
resolve: {
36+
alias: {
37+
"@root": path.resolve(__dirname, "../src"),
38+
},
39+
extensions: [".ts", ".tsx", ".js", ".json"]
40+
},
41+
module: {
42+
rules: [
43+
{enforce: "pre", test: /\.js$/, loader: "source-map-loader"},
44+
{
45+
test: /\.tsx?$/,
46+
use: [
47+
{
48+
loader: 'ts-loader',
49+
options: {
50+
transpileOnly: true
51+
}
52+
}
53+
]
54+
}
55+
]
56+
},
57+
plugins: [
58+
new ForkTsCheckerWebpackPlugin({
59+
tsconfig: path.resolve(__dirname, "../tsconfig.json"),
60+
tslint: path.resolve(__dirname, "../tslint.json"),
61+
}),
62+
63+
new HtmlWebpackPlugin({
64+
template: "../src/app.html",
65+
filename: "index.html",
66+
}),
67+
new webpack.HotModuleReplacementPlugin(),
68+
69+
// prints more readable module names in the browser console on HMR updates
70+
//new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/),
71+
72+
],
73+
}

0 commit comments

Comments
 (0)