Initializing Shopware PWA¶
Running Shopware PWA¶
This guide is based on the official documentation of Shopware PWA.
(0.) Install SwagShopwarePwa Plugin
Download a plugin packed in a zip file from github: master version
Log in to the admin panel at https://your-awesome-shopware-project.test/admin
Go to Setting > System > Plugins and click Upload plugin button.
When the plugin is uploaded - just install and activate it. That’s all. Shopware 6 is shopware-pwa ready now!
Or to do it programmatically run the following commands inside your Shopware Reward Shell:
wget https://github.com/elkmod/SwagShopwarePwa/archive/master.zip -O ~/swpwa.zip
php bin/console plugin:zip-import ~/swpwa.zip
Initialize Reward.
$ mkdir ~/Sites/shopware-pwa $ cd ~/Sites/shopware-pwa $ reward env-init shopware-pwa --environment-type=shopware-pwa
Sign a certificate for your project
$ reward sign-certificate shopware-pwa.test
Bring up the environment
$ reward env up
Create a regular PWA Project
$ reward shell $ npx @shopware-pwa/cli@canary init
Configure backend in
shopware-pwa.config.js
Update
package.json
and add these to thescripts
part"start": "yarn && yarn build --ci && node scripts/init.js --disable-host-check --public shopware-pwa.test" # you can use this script if you are familiar with jq DOMAIN="shopware-pwa.test" cat package.json | jq --arg domain "$DOMAIN" -Mr '. * {scripts:{start: ("yarn && yarn build --ci && node scripts/init.js --public " + $domain + " --disable-host-check")}}' | tee package.json
Note
We have to add both –disable-host-check (to skip host header verification) and –public (to let webpack dev server know it is behind a proxy and it shouldn’t add custom port to it’s callback URLs).
https://webpack.js.org/configuration/dev-server/#devserverpublic
Install dependencies
$ reward shell $ yarn
Restart the PWA container
$ reward env restart
Optional: if you’d like to run the project in Developer/Production mode, add the following line to your
.env
file# Developer Mode (default) DOCKER_START_COMMAND="yarn dev" # Production Mode DOCKER_START_COMMAND="yarn start"