Skip to content

Commit 8af1ed2

Browse files
chore(HMR): make website HMR able
1 parent 7f9d2ab commit 8af1ed2

File tree

5 files changed

+115
-26
lines changed

5 files changed

+115
-26
lines changed

package-lock.json

Lines changed: 68 additions & 19 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
},
2424
"dependencies": {
2525
"@babel/core": "^7.2.2",
26+
"@babel/plugin-syntax-dynamic-import": "^7.2.0",
27+
"@babel/plugin-transform-runtime": "^7.2.0",
2628
"@babel/preset-env": "^7.2.0",
2729
"@types/node": "10.5.1",
2830
"color": "3.0.0",
@@ -41,15 +43,15 @@
4143
"preact-compat": "3.18.4",
4244
"prismjs": "1.15.0",
4345
"query-string": "6.2.0",
46+
"react": "16.8.1",
47+
"react-dom": "16.8.1",
4448
"react-hot-loader": "^4.3.4",
4549
"styled-components": "3.3.3",
4650
"tslib": "1.9.3",
4751
"vue": "2.5.16",
4852
"vue-hot-reload-api": "2.3.0",
4953
"vue-styled-components": "1.3.0",
50-
"ws": "5.2.1",
51-
"react": "16.8.1",
52-
"react-dom": "16.8.1"
54+
"ws": "5.2.1"
5355
},
5456
"devDependencies": {
5557
"@babel/core": "7.2.2",
@@ -60,7 +62,7 @@
6062
"@types/react": "16.7.13",
6163
"@types/react-dom": "16.0.6",
6264
"@vue/component-compiler-utils": "2.1.0",
63-
"babel-loader": "8.0.0-beta.4",
65+
"babel-loader": "^8.0.5",
6466
"babel-plugin-transform-vue-jsx": "3.7.0",
6567
"commitizen": "^2.10.1",
6668
"concurrently": "3.6.1",

packages/overmind-website/src/components/App/index.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import Api from '../Api'
1111
import MobileTopBar from '../MobileTopBar'
1212
import { useIsMobile, useScrollToPosition } from '../../utils'
1313
import Footer from '../Footer'
14+
import { hot } from 'react-hot-loader/root'
1415

1516
const pages = {
1617
[Page.HOME]: FrontPage,
@@ -62,4 +63,4 @@ const App: SFC = () => {
6263
)
6364
}
6465

65-
export default App
66+
export default hot(App)

packages/overmind-website/src/index.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@ import { render } from 'react-dom'
33
import { injectGlobal } from 'emotion'
44
import * as iconFont from './icomoon.woff2'
55
import App from './components/App'
6+
import { setConfig } from 'react-hot-loader'
7+
8+
setConfig({
9+
ignoreSFC: true, // RHL will be __completely__ disabled for SFC
10+
pureRender: true, // RHL will not change render method
11+
})
612

713
injectGlobal`
814
@font-face {

packages/overmind-website/webpack.config.js

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ module.exports = (env, args) => {
3838
'/backend': 'http://localhost:5000',
3939
},
4040
historyApiFallback: true,
41+
hot: true,
4142
},
4243
module: {
4344
rules: [
@@ -55,12 +56,42 @@ module.exports = (env, args) => {
5556
},
5657
{
5758
test: /\.tsx?$/,
58-
loader: 'ts-loader',
59+
loader: 'babel-loader',
5960
include: path.join(__dirname, 'src'),
6061
options: {
61-
allowTsInNodeModules: true,
62+
presets: [
63+
[
64+
'@babel/preset-typescript',
65+
{
66+
isTSX: true,
67+
jsxPragma: 'createElement',
68+
allExtensions: true,
69+
},
70+
],
71+
[
72+
'@babel/preset-react',
73+
{
74+
pragma: 'createElement',
75+
},
76+
],
77+
'@babel/preset-env',
78+
],
79+
plugins: [
80+
'@babel/plugin-syntax-dynamic-import',
81+
[
82+
'@babel/plugin-transform-runtime',
83+
{
84+
regenerator: true,
85+
},
86+
],
87+
],
6288
},
6389
},
90+
{
91+
test: /\.tsx/,
92+
include: /node_modules/,
93+
loader: 'react-hot-loader/webpack',
94+
},
6495
],
6596
},
6697
resolve: {

0 commit comments

Comments
 (0)