react项目刷新、打包后白屏问题解决

  1. 项目配置 @craco/craco ,可参考博客

  1. craco.config.js添加如下配置

// 顶部引入path
const path = require("path");
 
 
module.exports = {
 
  ...
 
  webpack: {
    configure: (webpackConfig) => {
      // 设置publicPath
      webpackConfig.output.publicPath = webpackConfig.mode === "production" ? './' : '';
      return webpackConfig
    }
  }
 
  ...
 
}

你可能感兴趣的:(react,webpack,前端,react.js,webpack)