GeezerVison is showing github.com — :construction: apply loader to silence HMR logs · nullstack/nullstack@20fda52
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: client/index.js -3Lines changed: 0 additions & 3 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -2,7 +2,6 @@ import element from '../shared/element' | 2 | 2 | import fragment from '../shared/fragment' | 3 | 3 | import generateTree from '../shared/generateTree' | 4 | 4 | import { loadPlugins, useClientPlugins } from '../shared/plugins' | 5 | | -import dangerouslySilenceHmr from '../shared/silenceHmr' | 6 | 5 | import client from './client' | 7 | 6 | import context, { generateContext } from './context' | 8 | 7 | import environment from './environment' | @@ -107,8 +106,6 @@ export default class Nullstack { | 107 | 106 | } | 108 | 107 |
| 109 | 108 | if (module.hot) { | 110 | | - dangerouslySilenceHmr() | 111 | | - | 112 | 109 | function pingAndReload() { | 113 | 110 | const source = new window.EventSource('/nullstack/hmr') | 114 | 111 | let shouldReconnect = false | |
Collapse file Copy file name to clipboard +12Lines changed: 12 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| | 1 | +module.exports = function removeStaticFromClient(source) { | | 2 | + const injection = ` | | 3 | + const console = { | | 4 | + log: () => {}, | | 5 | + error: () => {}, | | 6 | + debug: () => {}, | | 7 | + info: () => {}, | | 8 | + warn: () => {} | | 9 | + }; | | 10 | + ` | | 11 | + return injection + source | | 12 | +} |
Collapse file Copy file name to clipboardExpand all lines: server/hmr.js -4Lines changed: 0 additions & 4 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 2 | 2 | import { existsSync } from 'fs' | 3 | 3 | import path from 'path' | 4 | 4 |
| 5 | | -import dangerouslySilenceHmr from '../shared/silenceHmr' | 6 | | - | 7 | 5 | export default function hmr(server) { | 8 | 6 | if (module.hot) { | 9 | | - dangerouslySilenceHmr() | 10 | | - | 11 | 7 | const customConfig = path.resolve(process.cwd(), 'webpack.config.js') | 12 | 8 | const webpackConfigs = existsSync(customConfig) | 13 | 9 | ? __non_webpack_require__(customConfig) | |
Collapse file Copy file name to clipboardExpand all lines: shared/silenceHmr.js -13Lines changed: 0 additions & 13 deletions Collapse file Copy file name to clipboardExpand all lines: webpack.config.js +16-6Lines changed: 16 additions & 6 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -16,12 +16,6 @@ function getLoader(loader) { | 16 | 16 | return path.posix.join(loaders, loader) | 17 | 17 | } | 18 | 18 |
| 19 | | -const originalLog = console.log | 20 | | -global.console.log = function (...args) { | 21 | | - if (args[0] && args[0].toString().startsWith('[nodemon-webpack-plugin]')) return | 22 | | - originalLog(...args) | 23 | | -} | 24 | | - | 25 | 19 | function cacheFactory(args, folder, name) { | 26 | 20 | if (args.cache || args.environment === 'development') { | 27 | 21 | return { | @@ -374,6 +368,14 @@ function server(env, argv) { | 374 | 368 | resourceQuery: /raw/, | 375 | 369 | type: 'asset/source', | 376 | 370 | }, | | 371 | + { | | 372 | + test: /webpack[\\\/]hot/, | | 373 | + loader: getLoader('shut-up-loader.js') | | 374 | + }, | | 375 | + { | | 376 | + test: /webpack-hot-middleware/, | | 377 | + loader: getLoader('shut-up-loader.js') | | 378 | + } | 377 | 379 | ], | 378 | 380 | }, | 379 | 381 | target: 'node', | @@ -500,6 +502,14 @@ function client(env, argv) { | 500 | 502 | test: /\.(njs|nts|jsx|tsx)$/, | 501 | 503 | loader: getLoader('transform-node-ref.js'), | 502 | 504 | }, | | 505 | + { | | 506 | + test: /webpack[\\\/]hot/, | | 507 | + loader: getLoader('shut-up-loader.js') | | 508 | + }, | | 509 | + { | | 510 | + test: /webpack-hot-middleware/, | | 511 | + loader: getLoader('shut-up-loader.js') | | 512 | + } | 503 | 513 | ], | 504 | 514 | }, | 505 | 515 | target: 'web', | |
|