ScandiPWA (deprecated)
User ManualGitHubSlack
  • ScandiPWA (deprecated)
  • React & PWA for dummies
    • Setting Up Environment and Talking Theory
    • Learning React Hands-on
    • Styling It
    • Learning ScandiPWA Way
  • START & UPGRADE
    • Linux Docker setup
    • Mac Docker setup
    • Setting up the theme with remote M2 server
    • Theme Upgrade to the latest version
    • Automated setup (BETA)
  • A TO Z OVERVIEW
    • Motivation
    • Challenges
    • File structure and UI components
    • Rewriting and Extending A Theme
  • DESCRIPTION OF CONTAINERS
    • Ngrok
  • FAQ
    • Development
    • Installation
    • Billing and license
    • Product support
    • What is PWA?
  • HOW-TO TUTORIALS - INTRODUCTORY
    • Base template
    • Connecting to the GraphQL resolver
    • Extension mechanism
    • Creating GraphQL resolver
    • Debugging and Inspecting
    • Setting Up Frontend
    • File Structure
    • Data Flow
    • Technology Stack
    • Changing environment
    • Theme Build and Configuration
    • Implementing Caching for New Caching Identities
    • Implementing a parent theme
  • HOW-TO TUTORIALS - INTERMEDIATE
    • Debugging in Chrome
    • Configuring XDebug
    • CLI in Docker
    • Postman & GraphQL Playground
    • VSCode Extensions
    • Plugins: implementing
    • Plugins: using and publishing
    • ESlint & StyleLint
    • How To Contribute
    • Migrating to a Newer Version
    • Installation on Existing Magento 2 Sever
    • BEM and Coding Standards
    • Tools of ScandiPWA
    • React Best Practices
  • FAQ
    • Untitled
Powered by GitBook
On this page
  • What Is A Front-End Container?
  • How To Start The Development Set-Up?
  • Working With The Front-End Container: Difference Between The Production And Development Set-Up
  • The Development Set-Up
  • The Production Set-Up
  • Overriding A Component: Step-By-Step Walkthrough
  1. HOW-TO TUTORIALS - INTRODUCTORY

Setting Up Frontend

PreviousDebugging and InspectingNextFile Structure

Last updated 4 years ago

Topics covered in this tutorial:

What Is A Front-End Container?

ScandiPWA Docker set-up comes with two options. You can either wither with or without front-end.

A front-end container completely replaces the front-end for the application. So, instead of the Magento server providing you with the front-end, the webpack dev server does it.

How To Start The Development Set-Up?

To start the development set-up use:

docker-compose -f docker-compose.yml -f docker-compose.local.yml -f docker-compose.ssl.yml -f docker-compose.frontend.yml up -d --remove-orphans

Or, if you have this alias set up

# docker-compose with front-end
alias dcf="docker-compose -f docker-compose.yml -f docker-compose.local.yml -f docker-compose.ssl.yml -f docker-compose.frontend.yml"

use

dcf up -d --remove-orphans

Working With The Front-End Container: Difference Between The Production And Development Set-Up

PRODUCTION SET-UP

DEVELOPMENT SET-UP

...-f frontend.compose.frontend.yml...

M2 handles all requests

/graphql, /admin —> M2 back-end server

npm run build

/category, /123 etc. —> webpack dev server

Customization works

No customization

URL rewrites work

No URL/rewrites/redirects

Dev server watches the files

In-memory caching - quick recompilation

The Development Set-Up

  • To start, use an additional file docker-compose-frontend.yml or the dcf alias.

  • /graphql and /admin will be handled by Magento.

  • /category, /products etc. will be handled by the webpack dev server

    • The webpack dev-server will be running in a container called frontend.

  • No customization abilities.

    • ScandiPWA supports color and content customization, however, it won’t function in development mode

  • No URL rewrites/redirects .

    • Magento router is not involved in the response generation, instead it is done by the webpack dev server.

    • What are the pluses of this approach?

      • Dev server watches the files from your theme directory app/design/frontend/Scandiweb/pwa. Recompiles after every change.

      • In-memory caching allows for quick recompilation of only the files which are changed or hot-reloading.

The Production Set-Up

  • Every request is handled by Magento

  • Any change in the ScandiPWA folder will require for you to run the command npm run build from its directory.

    • Any change requires full recompilement unlike in the development mode, where only the changed files are recompiled.

  • URL rewrites work

  • Customization works

    • If you want to check out your customization, you need to switch into production mode and remove -f docker-compose.frontend.yml from the stack

Note:

The first set-up must be done in production mode, without the front-end container

Overriding A Component: Step-By-Step Walkthrough

If you don’t want to debug, change the .env file’s PROJECT-IMAGE = xdebug to PROJECT-IMAGE = latest. Now, when force recreating with dcf up -d --remove-orphans we see that the front-end container gets set up.

Use the alias frontlogs or dcf logs -f frontend to see what the state of the application is.

If you see the following output, the front-end is ready. You can open a browser and go to scandipwa.local to make sure that, indeed, the front-end is ready and will hot-reload.

ℹ 「wdm」: Compiled successfully

Open the folder scandipwa-base/src/app/design/frontend/Scandiweb/pwa/src and create an app folder in it.

Assuming that you have the extension installed, search for ScandiPWA: Extend source component and select Breadcrumbs as a component to override. Press ok and then Extend them!.

Let’s check-out where the breadcrumbs are displayed on the web app. Go to your browser and type scandipwa.local. Then go to “woman” > “dresses” for example, and right-click “Inspect element”.

For this example we’re interested in where the color of Breadcrumbs is and upon further inspection we can see that it happens in the .Breadcrumbs block.

Return back to the Breadcrumbs.override.style.scss file and type the following.

:root{
  --breadcrumbs-background: red;
}

Go back to your browser to check if its working. You should see a red breadcrumb container. This happens because the front-end container immediately compiles the styles and anything else in the ScandiPWA front-end app.

You can check out one of our to find out more about the recommended aliases.

You can check out our docs for a on how to correctly set-up.

You can check out the ScandiPWA to improve the speed of your workflow.

You’ll see the Breadcrumbs.component.js file. Here eslint is already configured, but feel free to read more or , and check out the ScandiPWA .

Open the Breadcrumbs.override.style.scss file, it will be full of warnings due to the fact that is working.

You’ll see the element class Breadcrumbs and all of its children who have .Breadcrumbs-List styles. This is called BEM or Block Element Modifier and you can read more about it .

Docker set-up tutorials
step-by-step guide
VSCode extension
here
here
eslint plug-in
stylelint
here
How To Start The Development Set-Up?
Working With The Front-End Container: Difference Between The Production And Development Set-Up
Overriding A Component: Step-By-Step Walkthrough
Setting Up ScandiPWA Frontend