标签: razzle

Material UI:页面初始加载时闪烁(Razzle)

我在服务器端渲染应用程序中集成了材质 UI,并遵循了此处给出的代码。Material UI css 已添加到服务器端本身的 html 中。

但是,在初始加载时,不会应用材质 ui 样式,这会导致它闪烁。

我尝试<cssbaseline>与下面的代码一起使用,但没有看到任何区别。

这是我的代码:server.js

import App from '../common/containers/App';
import { Provider } from 'react-redux';
import React from 'react';
import configureStore from '../common/store/configureStore';
import express from 'express';
import qs from 'qs';
import { renderToString } from 'react-dom/server';
import serialize from 'serialize-javascript';
import { StaticRouter, matchPath } from 'react-router-dom';
import {theme} from '../theme';
import { ServerStyleSheets, ThemeProvider } from '@material-ui/styles';
import routes from './routes'
import "../common/assets/SCSS/app.scss";

const assets = require(process.env.RAZZLE_ASSETS_MANIFEST); …
Run Code Online (Sandbox Code Playgroud)

reactjs material-ui server-side-rendering razzle

10
推荐指数
1
解决办法
692
查看次数

将 CRA 迁移到 Razzle

我有一个使用 Create React 应用程序构建的项目。我现在需要为我的应用程序进行服务器渲染,我发现 Razzle 是最简单的实现方法。

我有 /src,其中包含所有组件,此外还有一个图像文件夹以及公共文件夹中的一些内容。最后是 node_modules 文件夹,我在 package.json 中有依赖项

我应该将它们复制粘贴到 Razzle 吗?我已经尝试过,但收到错误webpack_require和 TypeError: 无法读取未定义的属性“原型”?

转换为 Razzle 的最佳方式是什么?

谢谢

frontend web-frontend reactjs razzle

5
推荐指数
0
解决办法
321
查看次数

ChunkLoadError: Loading chunk XY failed. - Randomly getting fatal on PRODUCTION

we have got our ecommerce platform already in production and we are experiencing weird ChunkLoadError. This error happens randomly, and is not replicable. When we are trying to open failed file it is there and can be loaded normaly.

If user get's this error, he get's white screen (logicaly) but after refresh everything is fine.

We are running SSR ecommerce on React (latest), Express (latest)

our webpack / razzle config


const path = require('path');
const autoprefixer = require('autoprefixer');
const MiniCssExtractPlugin …
Run Code Online (Sandbox Code Playgroud)

express reactjs webpack-splitchunks razzle loadable-component

4
推荐指数
1
解决办法
8443
查看次数

在 react ssr 应用程序中调用 firebase 消息传递方法时,如何修复 self 未定义?

我正在尝试在使用https://github.com/jaredpalmer/razzle with-react-router-3创建的 SSR 应用程序中使用 firebase 按摩。我已经在使用 Firebase,它非常有效,包括托管。但是当我开始在应用程序中添加消息时开始抛出错误。

我的入口点看起来像,

import firebase from 'firebase/app';
import 'firebase/auth';
import 'firebase/database';
import 'firebase/storage';
import 'firebase/firestore';
import 'firebase/messaging';

import FirebaseConfig from 'config/firebase-config.json';
if (!firebase.apps.length) {
  firebase.initializeApp(FirebaseConfig);
}
const messaging = firebase.messaging();
Run Code Online (Sandbox Code Playgroud)

当我使用以下命令启动服务器时出现以下错误 razzle start

/Users/subkundu/Desktop/Work/Projects/React/ownerstown/node_modules/@firebase/messaging/index.ts:75
  if (self && 'ServiceWorkerGlobalScope' in self) {
  ^

ReferenceError: self is not defined
Run Code Online (Sandbox Code Playgroud)

我如何解决它?任何领先都将是惊人的。谢谢。:)

firebase reactjs firebase-cloud-messaging react-ssr razzle

3
推荐指数
1
解决办法
2371
查看次数

当我运行 React Razzle 应用程序时,出现错误“无法在模块外部使用 import 语句”

Razzle 是一个服务器端渲染框架。

这是错误:

/home/ajay/Ajay Nagotha/Projects/react-ssr-demo/luma-ssr/node_modules/react-bootstrap/esm/Container.js:1
import classNames from 'classnames';
^^^^^^

SyntaxError: Cannot use import statement outside a module
Run Code Online (Sandbox Code Playgroud)

node.js reactjs react-bootstrap razzle

3
推荐指数
1
解决办法
1万
查看次数

Razzle - 在构建文件夹中运行 server.js 时未找到 React 错误

我将 Razzle 用于服务器端渲染的 React 应用程序。

现在是在服务器上部署应用程序的时候了。我使用 IIS 作为 Web 服务器。但是,当我将构建文件夹移动到另一个目录并在其上运行节点服务器时,会出现无法找到我在应用程序中使用的模块的错误,例如 react.js。

internal/modules/cjs/loader.js:638
    throw err;
    ^
Error: Cannot find module 'react'
...
Run Code Online (Sandbox Code Playgroud)

我应该用 build 文件夹移动 node_modules 文件夹吗?还是我做错了什么?

javascript deployment node.js reactjs razzle

1
推荐指数
1
解决办法
841
查看次数