init
This commit is contained in:
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
node_modules
|
||||||
|
dist
|
||||||
17
index.html
Normal file
17
index.html
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8" />
|
||||||
|
<title>Hello React!</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div id="example"></div>
|
||||||
|
|
||||||
|
<!-- Dependencies -->
|
||||||
|
<script src="./node_modules/react/umd/react.development.js"></script>
|
||||||
|
<script src="./node_modules/react-dom/umd/react-dom.development.js"></script>
|
||||||
|
|
||||||
|
<!-- Main -->
|
||||||
|
<script src="./dist/bundle.js"></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
22
package.json
Normal file
22
package.json
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
{
|
||||||
|
"name": "minbin",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"description": "",
|
||||||
|
"main": "index.js",
|
||||||
|
"scripts": {
|
||||||
|
"test": "echo \"Error: no test specified\" && exit 1"
|
||||||
|
},
|
||||||
|
"author": "",
|
||||||
|
"license": "ISC",
|
||||||
|
"dependencies": {
|
||||||
|
"react": "^16.2.0",
|
||||||
|
"react-dom": "^16.2.0",
|
||||||
|
"react-redux": "^5.0.6"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"awesome-typescript-loader": "^3.4.1",
|
||||||
|
"redux-devtools": "^3.4.1",
|
||||||
|
"source-map-loader": "^0.2.3",
|
||||||
|
"typescript": "^2.6.2"
|
||||||
|
}
|
||||||
|
}
|
||||||
17
src/components/Hello.tsx
Normal file
17
src/components/Hello.tsx
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
import * as React from "react";
|
||||||
|
import RaisedButton from 'material-ui/RaisedButton'
|
||||||
|
export interface HelloProps { compiler: string; framework: string; }
|
||||||
|
|
||||||
|
// 'HelloProps' describes the shape of props.
|
||||||
|
// State is never set so we use the '{}' type.
|
||||||
|
export class Hello extends React.Component<HelloProps, {}> {
|
||||||
|
render() {
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<h1>Hello from {this.props.compiler} and {this.props.framework}!</h1>
|
||||||
|
<RaisedButton label="Default" />
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
19
src/index.tsx
Normal file
19
src/index.tsx
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
import * as React from "react";
|
||||||
|
import * as ReactDOM from "react-dom";
|
||||||
|
import MuiThemeProvider from 'material-ui/styles/MuiThemeProvider';
|
||||||
|
import { Hello } from "./components/Hello";
|
||||||
|
import darkBaseTheme from 'material-ui/styles/baseThemes/lightBaseTheme';
|
||||||
|
import getMuiTheme from 'material-ui/styles/getMuiTheme';
|
||||||
|
const darkMuiTheme = getMuiTheme(darkBaseTheme);
|
||||||
|
|
||||||
|
|
||||||
|
const App = () => (
|
||||||
|
<MuiThemeProvider muiTheme={darkMuiTheme}>
|
||||||
|
<Hello compiler="theme prov" framework="React" />
|
||||||
|
</MuiThemeProvider>
|
||||||
|
);
|
||||||
|
|
||||||
|
ReactDOM.render(
|
||||||
|
<App />,
|
||||||
|
document.getElementById("example")
|
||||||
|
);
|
||||||
13
tsconfig.json
Normal file
13
tsconfig.json
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"outDir": "./dist/",
|
||||||
|
"sourceMap": true,
|
||||||
|
"noImplicitAny": true,
|
||||||
|
"module": "commonjs",
|
||||||
|
"target": "es6",
|
||||||
|
"jsx": "react"
|
||||||
|
},
|
||||||
|
"include": [
|
||||||
|
"./src/**/*"
|
||||||
|
]
|
||||||
|
}
|
||||||
34
webpack.config.js
Normal file
34
webpack.config.js
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
module.exports = {
|
||||||
|
entry: "./src/index.tsx",
|
||||||
|
output: {
|
||||||
|
filename: "bundle.js",
|
||||||
|
path: __dirname + "/dist"
|
||||||
|
},
|
||||||
|
|
||||||
|
// Enable sourcemaps for debugging webpack's output.
|
||||||
|
devtool: "source-map",
|
||||||
|
|
||||||
|
resolve: {
|
||||||
|
// Add '.ts' and '.tsx' as resolvable extensions.
|
||||||
|
extensions: [".ts", ".tsx", ".js", ".json"]
|
||||||
|
},
|
||||||
|
|
||||||
|
module: {
|
||||||
|
rules: [
|
||||||
|
// All files with a '.ts' or '.tsx' extension will be handled by 'awesome-typescript-loader'.
|
||||||
|
{ test: /\.tsx?$/, loader: "awesome-typescript-loader" },
|
||||||
|
|
||||||
|
// All output '.js' files will have any sourcemaps re-processed by 'source-map-loader'.
|
||||||
|
{ enforce: "pre", test: /\.js$/, loader: "source-map-loader" }
|
||||||
|
]
|
||||||
|
},
|
||||||
|
|
||||||
|
// When importing a module whose path matches one of the following, just
|
||||||
|
// assume a corresponding global variable exists and use that instead.
|
||||||
|
// This is important because it allows us to avoid bundling all of our
|
||||||
|
// dependencies, which allows browsers to cache those libraries between builds.
|
||||||
|
externals: {
|
||||||
|
"react": "React",
|
||||||
|
"react-dom": "ReactDOM"
|
||||||
|
},
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user