Writing JavaScript for the WordPress frontend

There's a webpack setup in the root of pmc-nova, that can be run from the style-guide directory with npm run build:wp-asset.

Writing JavaScript

Create a new file in pmc-nova/src/js (ref (opens in a new tab)). Your file may be component-specific (e.g. mega-menu.js) or library or package-specific (e.g. flickity.js or sanitize.js), or something else entirely (e.g. ads.js).

Webpack will detect this file and build it.

Enqueuing built assets

You'll need to enqueue your assets inside of WordPress. If your script is component-specific, it should be enqueued in the corresponding class-controller.php. Refer to the Component Controller section for more information.

Otherwise, the enqueue belongs in \PMC\Nova\Theme\Assets.