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
  • Connecting VSCode to Google Chrome
  • Making A Configuration
  1. HOW-TO TUTORIALS - INTERMEDIATE

Debugging in Chrome

PreviousImplementing a parent themeNextConfiguring XDebug

Last updated 4 years ago

Tools you need to install in your Chrome browser:

The Components section includes the names of the components and the logic of them.

Note:

you can use the React Developer Tools in development mode

The React Developer Tools Chrome extension will not work in production mode, due to the fact that in the code optimisation process the code gets minified.

The Redux Devtools extension allows you to traverse the history of your application, i.e. see the process of navigation. We can also see the state which is currently in action, as well as see what actions had happened etc.

Connecting VSCode to Google Chrome

Open your VSCode editor, search for “Debugger for Chrome” and install it.

After this click on the application panel. Here we can see that our application either has or doesn’t have configurations. Click on the settings icon to see what configurations are available.

Making A Configuration

Select “Chrome” in the application configuration settings and open launch.json.

"configurations":[
  {
    "type": "chrome",
    "request": "launch",
    "name": "Launch Chrome against localhost",
    "url": "http://localhost:8080",
    "webRoot": "${workspaceFolder}",
  }
]

Here we don’t want Chrome to launch agains localhost, so change http://localhost:8080 to https://scandipwa.local and click the launch button.

The error [debugger for chrome] Error processing "launch": Can't find Chrome may happen if your version of the Chrome executable is different from the one VSCode has.

You can look for your executable by typing:

ls /bin | grep chrome

Instead of chrome your executable might be google-chrome-stable. In this case, you need to go back to VSCode and in the launch.json file provide a runtime executable pointing to your specific Chrome executable.

"configurations":[
  {
    "type": "chrome",
    "request": "launch",
    "name": "Launch Chrome against localhost",
    "url": "https://scandipwa.local",
    "webRoot": "${workspaceFolder}",
    "runtimeExecutable": "/bin/google-chrome-stable"
  }
]

After this, try launching again. If this doesn’t work, we can try launching Chrome separately and attach VSCode to it later. To do this you need to change the request to attach, also the runtime executable is not needed. If you want to declare a new port, you can add it to the configurations as well.

"configurations":[
  {
    "type": "chrome",
    "request": "attach",
    "name": "Launch Chrome against localhost",
    "url": "https://scandipwa.local",
    "webRoot": "${workspaceFolder}",
    "port": 9222 
  }
]

To run Chrome for VSCode attachment, you need to execute the following command:

google-chrome-stable --remote-debugging-port=9222 --user-data-dir=~/Downloads/debug-data

Executing this will open up Chrome, go to scandipwa.local, open up VSCode and try to launch again.

In the VSCode debug console we can see our browser logs, which we can compare with the browser by clicking “Inspect element” and “Console”. If they are the same, we can deduce that VSCode is connected to Chrome.

Run the ScandiPWA in development mode, go to scandipwa.local using Chrome and click on the “Components” section in devtools.

front-end container
Redux Devtools
React Developer Tools
How to debug in Chrome