yarn create @magento/pwayarn watch
Install globally:
npm install -g @magento/upward-js
And then run:
UPWARD_JS_UPWARD_PATH=/abc/upward.yml \UPWARD_JS_BIND_LOCAL=1 \UPWARD_JS_LOG_URL=1 \upward-js-server
You can guarantee that upward-js-server
remains running by using PM2
Create a new project (yarn init
) and add to it:
yarn add @magento/upward-js express
File example-express/example-server.js
:
const { createUpwardServer } = require('@magento/upward-js');async function serve() { await createUpwardServer({ port: 8000, bindLocal: true, logUrl: true, upwardPath: '/abc/upward.yml' });}serve();
Note that there only needs to be 1 file in this new repository
Usage:
node example-server.js
You can guarantee that example-server.js
remains running by using PM2
composer require magento/module-upward-connector
bin/magento module:enable Magento_UpwardConnector
/path/to/pwastudio/packages/venia-concept/dist/upward.yml
yarn build
) and deploy it to productiondist/upward.yml
upward-hello.yml
status: 200headers: inline: content-type: inline: text/htmlbody: inline: 'Hello World'
See: https://itnext.io/magento-pwa-studio-what-is-upward-acf450fbee3e
resource: when: - matches: urlResolver.type pattern: 'CMS_PAGE' use: inline: model: cmsPage name: cmsPage.title entityTypeName: inline: "Page" template: '../venia-ui/templates/cmspage-shell.mst'
See https://www.czettner.com/2020/02/14/magento-2-pwa-studio-ssr.html
open-document.mst
<head>
open-body.mst
<head>
, opening of <body>
close-document.mst
<body>
Usage in other file (example.mst
):
{{> templates/open-document}} <title>{{ title }}</title>{{> templates/open-body}} <b>Hello Template World!</b>{{> templates/close-document}}
File venia-ui/templates/cmspage-shell.mst
:
{{> templates/open-document}} {{#model}} <title>{{title}} - My awesome site</title> <meta name="title" content="{{meta_title}}"> <meta name="keywords" content="{{meta_keywords}}"> <meta name="description" content="{{meta_description}}"> {{/model}} {{> templates/open-body }} {{> templates/default-initial-contents }} {{> templates/seed-bundles}}{{> templates/close-document}}
venia-ui/templates/generic-shell.mst
venia-ui/templates/cmspage-shell.mst
venia-ui/templates/product-shell.mst
venia-ui/templates/category-shell.mst
Example snipper from UPWARD YAML:
query: resolver: file file: resolver: inline inline: './productDetail.graphql' encoding: resolver: inline inline: 'utf-8'
The property query
is filled with the contents of the GraphQL file
when
and matches
Remember that UPWARD has no state, so no caching
Remember that UPWARD has no state, so no caching
Remember that UPWARD has no state, so no caching
Remember that UPWARD has no state, so no caching
index.js
const apiBase = new URL('https://m2.vega.yr/graphql').toString();
server.js
, upward.yml
Keyboard shortcuts
↑, ←, Pg Up, k | Go to previous slide |
↓, →, Pg Dn, Space, j | Go to next slide |
Home | Go to first slide |
End | Go to last slide |
Number + Return | Go to specific slide |
b / m / f | Toggle blackout / mirrored / fullscreen mode |
c | Clone slideshow |
p | Toggle presenter mode |
t | Restart the presentation timer |
?, h | Toggle this help |
Esc | Back to slideshow |