razzle-app
デフォルトの裸の肌( https://github.com/jaredpalmer/razzle ) を取得して、にデプロイしたときに機能させることができませんでしたGoogle App Engine
。同形反応アプリを GAE にデプロイした経験がある人なら、どんな意見でもいいでしょう。
デプロイ後、server.js から html を提供します (ルートの html テキストのみを提供しますが、それ以外には何も提供しません。アプリケーションもページ上のアセットも提供しません)。概念実証として、ルートごとに異なる html コンテンツを返していましたが、html テキスト コンテンツと head タグが異なるため、明らかに機能します。ただし、サイトには静的アセットはありません (画像、css、js はありません)。
ビルド プロセスの出力:
razzle build
Creating an optimized production build...
Compiling client...
Compiled client successfully.
Compiling server...
Compiled server successfully.
Compiled successfully.
File sizes after gzip:
48.22 KB build/static/js/bundle.c798792d.js
333 B build/static/css/bundle.659481d8.css
ビルド ディレクトリには以下が含まれます。
> build
> public
> static
> css
> js
> media
> favicon and robots
> static
> media (same one as public/staic)
> assets.json
> server.js
build/static/js
が存在しないことに注意してください。中にありbuild/public/static/js
ます。変ですか?サイト (サーバーからの html テキストのみ) にアクセスする際に、クライアント バンドルが送信されたかどうかをヘッドで確認しました。間違った場所から取得しています。
<script src="http://localhost:8081/static/js/bundle.js" defer="" crossorigin=""></script>
私のpackage.jsonは次のようになります:
{
"name": "my-razzle-app",
"version": "0.1.0",
"license": "MIT",
"scripts": {
"start": "razzle start",
"build": "razzle build",
"test": "razzle test --env=jsdom",
"start:prod": "NODE_ENV=production node build/server.js"
},
"dependencies": {standard
"express": "^4.17.1",
"razzle": "^3.0.0",
"react": "^16.11.0",
"react-dom": "^16.11.0",
"react-router-dom": "^5.1.2"
}
}
GAE は npm run start を実行することに注意してください。
私は現在 flex を使用していますが、 standard はまったく機能しませんでした。app.yaml は次のようになります。
env: flex
runtime: nodejs
service: web
ローカルで実行中:
razzle start
WAIT Compiling...
✔ Client
Compiled successfully in 2.14s
✔ Server
Compiled successfully in 153.86ms
ℹ 「wds」: Project is running at http://localhost:3001/
ℹ 「wds」: webpack output is served from undefined
ℹ 「wds」: Content not from webpack is served from /home/anz/Cogi/timecloud-client/my-app
ℹ 「wds」: 404s will fallback to /index.html
✅ Server-side HMR Enabled!
started
localhost:3001 ではなく、localhost:3000 でアクセスできます。