Skip to content

Commit fd2e506

Browse files
committed
migration
1 parent 0addfb8 commit fd2e506

5 files changed

Lines changed: 57 additions & 18 deletions

File tree

front/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
"postprod": "react-snap",
3131
"analyze": "rimraf docs/assets && cross-env NODE_ENV=production webpack -p --config webpack.analyze.config.js",
3232
"prestart": "npm run clean-docs",
33-
"start": "cross-env NODE_ENV=dev webpack-dev-server --hot --config ./webpack.hot.reload.config.js --mode development"
33+
"start": "cross-env NODE_ENV=dev webpack-dev-server --hot --config ./webpack.hot.reload.config.js"
3434
},
3535
"reactSnap": {
3636
"source": "docs"

front/src/Root.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { ConnectedRouter } from 'connected-react-router';
44
import { Switch, Route } from 'react-router-dom';
55
import { Provider } from 'react-redux';
66
import { ThemeProvider } from 'styled-components';
7+
import { hot } from 'react-hot-loader';
78
import configureStore from './redux/store/configureStore';
89
import { history } from './redux/store/configureStore';
910
import ScrollTop from './components/scrollToTop/ScrollToTop';
@@ -55,4 +56,4 @@ class Root extends Component<Props, State> {
5556
}
5657
}
5758

58-
export default Root;
59+
export default hot(module)(Root);

front/src/index.tsx

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
// import 'babel-polyfill';
2-
import "core-js/stable";
3-
import "regenerator-runtime/runtime";
2+
import 'core-js/stable';
3+
import 'regenerator-runtime/runtime';
44
import 'bootstrap/dist/css/bootstrap.min.css';
5-
import { hot } from 'react-hot-loader/root';
5+
// import { hot } from 'react-hot-loader/root';
66
import React from 'react';
77
import { hydrate, render } from 'react-dom';
88
import smoothScrollPolyfill from 'smoothscroll-polyfill';
@@ -19,15 +19,16 @@ smoothScrollPolyfill.polyfill();
1919
(window as any).__forceSmoothScrollPolyfill__ = true;
2020
(window as any).snapSaveState = () => getState();
2121

22-
;(async () => {
23-
console.log('You have async support if you read this instead of "ReferenceError: regeneratorRuntime is not defined" error.');
24-
})()
22+
(async () => {
23+
console.log(
24+
'You have async support if you read this instead of "ReferenceError: regeneratorRuntime is not defined" error.',
25+
);
26+
})();
2527
// #endregion
2628

2729
// render app (hydrate for react-snap):
2830
function renderApp(RootComponent: any) {
29-
// @ts-ignore
30-
const Application = hot(RootComponent);
31+
const Application = RootComponent;
3132
// needed for react-snap:
3233
bootstrapedElement && bootstrapedElement.hasChildNodes()
3334
? loadComponents().then(() => hydrate(<Application />, bootstrapedElement))

front/tsconfig.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
"lib": ["dom", "es2015", "esnext"],
77
"module": "commonjs",
88
"moduleResolution": "node",
9-
"allowJs": false,
109
"checkJs": false,
1110
"allowSyntheticDefaultImports": true,
1211
"esModuleInterop": true,
@@ -19,7 +18,7 @@
1918
"resolveJsonModule": true,
2019
"outDir": "../dist/assets"
2120
},
22-
"include": ["./src"],
23-
"exclude": ["node_modules", "webpack.*"]
21+
"include": ["./src"]
22+
// "exclude": ["node_modules", "webpack.*"]
2423
// "exclude": ["node_modules", "!node_modules/@types", "*.d.ts"]
2524
}

front/webpack.hot.reload.config.js

Lines changed: 43 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -149,10 +149,16 @@ const indexFile = path.join(__dirname, 'src/index.tsx');
149149
// };
150150

151151
const config = {
152-
entry: ['./src'],
152+
mode: 'development',
153+
target: 'web',
154+
devtool: 'eval-source-map',
155+
entry: {
156+
app: [indexFile],
157+
},
153158
output: {
154-
path: path.join(__dirname, 'dist'),
155-
filename: 'bundle.js',
159+
path: path.join(__dirname, 'docs'),
160+
filename: '[name].js',
161+
chunkFilename: '[name].js',
156162
},
157163
resolve: {
158164
modules: ['node_modules'],
@@ -172,7 +178,6 @@ const config = {
172178
exclude: [nodeModulesDir],
173179
use: ['awesome-typescript-loader'],
174180
},
175-
176181
{
177182
test: /\.css$/,
178183
use: ['style-loader', 'css-loader'],
@@ -191,12 +196,45 @@ const config = {
191196
},
192197
],
193198
},
194-
devtool: 'eval-source-map',
199+
optimization: {
200+
runtimeChunk: false,
201+
splitChunks: {
202+
cacheGroups: {
203+
commons: {
204+
test: /[\\/]node_modules[\\/]/,
205+
name: 'vendors',
206+
chunks: 'all',
207+
},
208+
styles: {
209+
name: 'styles',
210+
test: /\.css$/,
211+
chunks: 'all',
212+
enforce: true,
213+
},
214+
},
215+
},
216+
},
217+
devServer: {
218+
host: 'localhost',
219+
port: 3001,
220+
historyApiFallback: true,
221+
contentBase: path.join(__dirname, 'temp'),
222+
headers: { 'Access-Control-Allow-Origin': '*' },
223+
},
195224
plugins: [
196225
new HtmlWebpackPlugin({
197226
template: 'index.html',
198227
}),
199228
new webpack.NamedModulesPlugin(),
229+
new webpack.DefinePlugin({
230+
'process.env': {
231+
NODE_ENV: JSON.stringify('dev'),
232+
},
233+
}),
234+
new ProgressBarPlugin({
235+
format: 'Build [:bar] :percent (:elapsed seconds)',
236+
clear: false,
237+
}),
200238
],
201239
};
202240

0 commit comments

Comments
 (0)