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
const buildpack = require('@magento/pwa-buildpack');
const MagentoResolver = buildpack.Webpack.MagentoResolver;
module.exports = async env => {
const config {
/* webpack entry, output, rules, etc */
resolve: await MagentoResolver.configure({
paths: {
root: __dirname
}
})
};
return config;
}

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 or share my personal information
  • AdChoices
Copyright © 2024 Adobe. All rights reserved.