Created
May 27, 2017 06:10
-
-
Save geakstr/f4755a096fde69f2ed2579fcc06c07e2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as React from "react"; | |
import * as ReactDOM from "react-dom"; | |
import { AppContainer } from "react-hot-loader"; | |
import RootContainer from "./RootContainer"; | |
const node = document.getElementById("app"); | |
const render = (Component: any) => ReactDOM.render(<AppContainer><Component /></AppContainer>, node); | |
render(RootContainer); | |
module.hot.accept(['./RootContainer.tsx'], () => { | |
console.log("RERENDER"); | |
const RootContainer = require("./RootContainer.tsx").default; | |
render(RootContainer); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as React from "react"; | |
export default () => <div>Hello</div>; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const path = require("path"); | |
const webpack = require("webpack"); | |
const HtmlWebpackPlugin = require("html-webpack-plugin"); | |
const root = path.resolve(__dirname, "../"); | |
module.exports = { | |
entry: [ | |
"react-hot-loader/patch", | |
"webpack-dev-server/client?http://localhost:8080", | |
"webpack/hot/only-dev-server", | |
path.resolve(root, "src/index.tsx"), | |
], | |
output: { | |
filename: "[name].js", | |
chunkFilename: "[name].js", | |
publicPath: "/", | |
}, | |
devtool: "inline-source-map", | |
devServer: { | |
contentBase: path.join(root, "src"), | |
publicPath: "/", | |
hot: true, | |
historyApiFallback: true, | |
}, | |
resolve: { | |
extensions: [".ts", ".tsx", ".js", ".jsx", ".json"], | |
}, | |
module: { | |
rules: [ | |
{ | |
test: /\.js$/, | |
loader: "babel-loader", | |
options: { | |
presets: [["es2015", { modules: false }], "react"], | |
plugins: ["transform-class-properties", "transform-object-rest-spread", "react-hot-loader/babel"], | |
}, | |
include: path.resolve(root, "src/"), | |
}, | |
{ | |
test: /\.(c|sa|sc)ss$/, | |
loaders: [ | |
{ | |
loader: "style-loader", | |
}, | |
{ | |
loader: "css-loader", | |
options: { | |
importLoaders: 1, | |
}, | |
}, | |
{ | |
loader: "sass-loader", | |
}, | |
], | |
}, | |
{ | |
test: /\.tsx?$/, | |
loaders: [ | |
{ | |
loader: "react-hot-loader/webpack", | |
}, | |
{ | |
loader: "awesome-typescript-loader", | |
}, | |
], | |
}, | |
{ | |
enforce: "pre", | |
test: /\.js$/, | |
loader: "source-map-loader", | |
}, | |
{ | |
test: /\.woff(2)?(\?v=[0-9]\.[0-9]\.[0-9])?$/, | |
loader: "url-loader?limit=10000&mimetype=application/font-woff", | |
}, | |
{ | |
test: /\.(ttf|eot|svg)(\?v=[0-9]\.[0-9]\.[0-9])?$/, | |
loader: "file-loader", | |
}, | |
], | |
}, | |
plugins: [ | |
new webpack.HotModuleReplacementPlugin(), | |
new webpack.NamedModulesPlugin(), | |
new webpack.DefinePlugin({ | |
"process.env.NODE_ENV": JSON.stringify("development"), | |
}), | |
new HtmlWebpackPlugin({ | |
template: path.resolve(root, "src/index.html"), | |
chunksSortMode: "dependency", | |
}), | |
], | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment