Edit in GitHubLog an issue

Magento resolver

An adapter that configures Webpack to resolve assets using Magento PWA conventions. This module generates a configuration object used in the resolve property of a Webpack config. The configuration object tells Webpack how to traverse the filesystem structure for assets required in source files.

API#

Currently, MagentoResolver does very little, but it's likely that the Magento development environment will require custom resolution rules in the future; this utility sets the precedent of the API for delivering those rules.

configure(options)#

Parameters:

  • options: - Configuration object that describes where the PWA storefront folders are located. Must have a root property set to the context (root directory) of the project.

Return:

A Promise configuration type for webpack.

Example#

In webpack.config.js:

Copied to your clipboard
1const buildpack = require('@magento/pwa-buildpack');
2const MagentoResolver = buildpack.Webpack.MagentoResolver;
3
4module.exports = async env => {
5 const config {
6 /* webpack entry, output, rules, etc */
7
8
9 resolve: await MagentoResolver.configure({
10 paths: {
11 root: __dirname
12 }
13 })
14
15 };
16
17 return config;
18}

The special __dirname variable in Node always refers to the directory containing the currently executing script file. This is different from the "working directory", which is the current directory of the shell when the current process was started.

  • Privacy
  • Terms of Use
  • Do not sell my personal information
  • AdChoices
Copyright © 2022 Adobe. All rights reserved.