Skip to content

Commit

Permalink
Update hot reload config
Browse files Browse the repository at this point in the history
  • Loading branch information
nukeop committed Oct 27, 2023
1 parent 723f7a1 commit e728fde
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 26 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion packages/app/app/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ import NavButtons from './components/NavButtons';
import WindowControls from './components/WindowControls';
import SidebarMenuContainer from './containers/SidebarMenuContainer';
import { CommandPaletteContainer } from './containers/CommandPaletteContainer';
import { hot } from 'react-hot-loader';

@withTranslation('app')
class App extends React.PureComponent {
Expand Down Expand Up @@ -202,5 +203,5 @@ export default withRouter(
connect(
mapStateToProps,
mapDispatchToProps
)(App)
)(hot(module)(App))
);
28 changes: 8 additions & 20 deletions packages/app/app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ import 'regenerator-runtime';
import 'semantic-ui-css/semantic.min.css';
import 'font-awesome/css/font-awesome.css';

import 'react-hot-loader/root';
import React from 'react';
import ReactDOM from 'react-dom';
import { MemoryRouter } from 'react-router-dom';
import { Provider } from 'react-redux';
import { AppContainer, setConfig } from 'react-hot-loader';
import { I18nextProvider } from 'react-i18next';
import { remote } from 'electron';
import { getOption, setOption } from '@nuclear/core';
Expand All @@ -16,10 +16,6 @@ import i18n, { setupI18n } from '@nuclear/i18n';
import App from './App';
import configureStore from './store/configureStore';

setConfig({
showReactDomPatchNotification: false
});

const store = configureStore();
window.store = store; // put store in global scope for plugins

Expand All @@ -36,23 +32,15 @@ const render = async Component => {
});

ReactDOM.render(
<AppContainer>
<I18nextProvider i18n={i18n}>
<Provider store={store}>
<MemoryRouter>
<Component />
</MemoryRouter>
</Provider>
</I18nextProvider>
</AppContainer>,
<I18nextProvider i18n={i18n}>
<Provider store={store}>
<MemoryRouter>
<Component />
</MemoryRouter>
</Provider>
</I18nextProvider>,
document.getElementById('react-root')
);
};

render(App);

if (module.hot) {
module.hot.accept(() => {
render(App);
});
}
2 changes: 1 addition & 1 deletion packages/app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@
"megalodon": "^3.6.1",
"mock-require": "^3.0.3",
"react-beautiful-dnd-test-utils": "^4.1.0",
"react-hot-loader": "^4.12",
"react-hot-loader": "^4.13.1",
"redux-mock-store": "^1.5.4",
"sass": "^1.69.5",
"sass-loader": "^10.4.1",
Expand Down
11 changes: 8 additions & 3 deletions packages/app/webpack.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ module.exports = (env) => {
? path.resolve(APP_DIR, 'index.js')
: [
'react-hot-loader/patch',
'webpack-dev-server/client?http://localhost:8080',
'webpack/hot/only-dev-server',
'webpack/hot/dev-server.js',
'webpack-dev-server/client/index.js?hot=true&live-reload=true',
path.resolve(APP_DIR, 'index.js')
];
const output: webpack.Configuration['output'] = {
Expand Down Expand Up @@ -118,8 +118,12 @@ module.exports = (env) => {
)
),
new webpack.ContextReplacementPlugin(
/\/(ytpl|ytsr|youtube-ext|bandcamp-scraper)\//,
/\/(ytpl|ytsr|youtube-ext|bandcamp-scraper|http-cookie-agent|deasync)\//,
false
),
new webpack.ContextReplacementPlugin(
/deasync/,
path.resolve(__dirname, 'node_modules', 'deasync', 'index.js')
)
];

Expand Down Expand Up @@ -237,6 +241,7 @@ module.exports = (env) => {
};

if (IS_DEV) {
config.plugins?.push(new webpack.HotModuleReplacementPlugin());
config.devServer = {
hot: true,
static: {
Expand Down

0 comments on commit e728fde

Please sign in to comment.