Skip to content

nmalecki/component-targetables

 
 

Repository files navigation

PWAStudio .targetables.js Plugins

Allows to use .targetables.js for PWAStudio

Usage Exsample

const { ExtendLocalIntercept } = require('@larsroettig/component-targetables');

function localIntercept(targets) {
    const { Targetables } = require('@magento/pwa-buildpack');
    const targetables = Targetables.using(targets);

    const extendLocalIntercept = new ExtendLocalIntercept(targetables);
    extendLocalIntercept.allowCustomTargetables();
    extendLocalIntercept.allowCssOverwrites();
}

module.exports = localIntercept;

Big shoutout to Chris Brabender for this blog post https://dev.to/chrisbrabender/simplifying-targetables-in-pwa-studio-p8b

Api Documentation

allowCssOverwrites

allowCssOverwrites(targetablesSearchPaths?, fileExtendsion?, magentoPath?): void

Parameters

Name Type Default value
targetablesSearchPaths string[] ['src/components', 'src/RootComponents']
fileExtendsion string '*.css'
magentoPath string 'node_modules/@magento'

Returns

void


allowCustomTargetables

allowCustomTargetables(targetablesSearchPaths?, fileExtendsion?, magentoPath?): void

Allows to place a custome targetable with given matching filepattern.

Parameters

Name Type Default value
targetablesSearchPaths string[] ['src/components', 'src/RootComponents']
fileExtendsion string '*.targetables.js'
magentoPath string 'node_modules/@magento'

Returns

void

Demo

https://github.com/larsroettig/demo-component-targetables

About

Allows to use .targetables.js for PWAStudio

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • TypeScript 88.5%
  • JavaScript 11.5%