Kanopi Pack is tool set designed to consolidate and ease the management of CSS and JS assets used in a web application along with the supporting packages which build them. The project is available for installation via NPM and documentation of the Why, When, and How for the tool are published in the Github repository
. Below, they are detailed in the steps recommended. This is meant to be a high-level overview with explanations. Considerations may be needed on a project-to-project basis.
Composer
Docksal
WP Config
MU Plugins
Theme
CircleCI and Tugboat changes are not referenced here, as that should be handled by the TechOps team. However, any compiled changes should NOT be stored in the repo, and instead, handled via CI.
Composer
In your project root, you will need to have a composer.json file. This is separate from your WordPress theme files.
You should ensure that the name is unique to your project. It’s highly suggested that you match this to the GitHub repo name (in this case, ftd-fpi).
The example composer.json file below is for a Pantheon-based, fully composer build.
Remove the johnpbloch/wordpress-core package if you do not manage core via Composer. However, the rest is required for use of the Kanopi Pack Asset Loader, and the updated PHPCS standards.
If you do manage core via Composer, to add contributed plugins, run composer require wpackagist-plugin/[plugin name]. You can search for these on WPackagist, or simply by taking the slug from the official Plugin repo, and using that for the plugin name.
This sample uses PHPCS, you can read more about WordPress configuration of PHPCS in this
IMPORTANT: This is a blueprint which is not up to date. The listed versions of packages are being updated regularly, please check and update the version of PHP, WordPress Core, and Kanopi Pack based on the latest supported version available through NPM and Composer.
NOTE: If your project is a Pantheon-hosted site, the root of your WordPress site and hence its files are in the web/ subfolder. Sites on WPEngine and many legacy support projects store WordPress in the root directory. Check configuration file paths to ensure they use the correct root path.
For Kanopi Pack to be able to run its development server, you will need to add the following code to your wp-config-local.php (for Pantheon) or wp-config.php (for WPEngine and other projects):
/**
* For Front-end Development Server to be served via @kanopi/pack
For Docksal configurations, keep a copy of this configuration file in .docksal/etc/config and copy it into the root of the WordPress site in the init-site command.
MU-Plugins
Within the mu-plugins folder, situated under wp-content, you will need the following code added. The filename suggestion is 001-kanopi-app-loader.php. This is required for the Asset Loader to work. Please make sure to exclude it from the .gitignore.
<?php
/**
* Plugin Name: Kanopi MU Plugin Application Loader
* Author: Kanopi, Inc.
* Author URI: https://kanopi.com
* Description: Kanopi Autoloader initializes Composer-based Autoloader along with required plugins
*
* @wordpress-plugin
* Version: 1.0.0
*/
// Run the autoloader for the site if not loaded externally
if ( ! class_exists( 'Kanopi\Assets\Registry\WordPress' ) ) {
if ( ! file_exists( WP_CONTENT_DIR . '/mu-plugins/vendor/autoload.php' ) ) {