常见问题汇总
Babel 快速升级问题
语雀内容
自定义扩展或查看打印 Webpack 配置
语雀内容
禁用图片压缩插件 imagemin-webpack-plugin 安装
语雀内容
React 文件热更新入口配置模板
import React from 'react';import ReactDom from 'react-dom';import { AppContainer } from 'react-hot-loader';import Entry from '${this.resourcePath.replace(/\\/g, '\\\\')}';const state = window.__INITIAL_STATE__;const render = (App)=>{ // 如果是 SSR 渲染时,请用 hydrate, 否则用 render,主要解决警告问题,不影响实际功能 ReactDom.hydrate(EASY_ENV_IS_DEV ? <AppContainer><App {...state} /></AppContainer> : <App {...state} />, document.getElementById('app'));};if (module.hot) { module.hot.accept('${this.resourcePath.replace(/\\/g, '\\\\')}', () => { render(Entry); });}render(Entry);
热更新 HMR 生效,但页面没有更新
if (module.hot) { module.hot.accept('${this.resourcePath.replace(/\\/g, '\\\\')}', () => { render(Entry); });}改成if (module.hot) { module.hot.accept();}
更多常见问题