weprovide/aviate-wordpress

This package is abandoned and no longer maintained. No replacement package was suggested.

Aviate implementation for WordPress

Installs: 543

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 4

Forks: 0

Type:wordpress-muplugin

0.1.1 2017-10-31 12:42 UTC

This package is not auto-updated.

Last update: 2024-05-28 09:45:31 UTC


README

Aviate implementation for WordPress.

Installation

composer require weprovide/aviate-wordpress

Usage

const path = require('path')
const env = process.env.NODE_ENV || 'development'
const isDev = env === 'development'

module.exports = {
    distLocations: [
        path.join(__dirname, 'web/app/themes/yourtheme/dist')
    ],
    decorateConfig(config) {
        config.output.publicPath = isDev ? host : './'

        config.entry = Object.assign({}, config.entry, {
            'styles': [
                path.join(__dirname, 'web/app/themes/yourtheme/assets/styles/main.scss')
            ],
            'javascript': [
                path.join(__dirname, 'web/app/themes/yourtheme/assets/javascript/main.js')
            ]
        })

        return config
    }
}

Adding custom files

aviate.config.js:

const path = require('path')
const env = process.env.NODE_ENV || 'development'
const isDev = env === 'development'

module.exports = {
    distLocations: [
        path.join(__dirname, 'web/app/themes/yourtheme/dist')
    ],
    decorateConfig(config) {
        config.output.publicPath = isDev ? host : './'

        config.entry = Object.assign({}, config.entry, {
            'styles': [
                path.join(__dirname, 'web/app/themes/yourtheme/assets/styles/main.scss')
            ],
            'javascript': [
                path.join(__dirname, 'web/app/themes/yourtheme/assets/javascript/main.js')
            ],
            'your-file': [
                path.join(__dirname, 'web/app/themes/yourtheme/assets/javascript/example.js')
            ]
        })

        return config
    }
}

functions.php:

<?php
namespace YourVendor\YourTheme;

function aviateFiles($files, $aviate) {
	if($aviate->isDevelopment()) {
		$files['js'][] = $aviate->getDevServerUrl('your-file.js');
		return $files;
	}

	$files['js'][] = $aviate->getProductionUrl('your-file.js');

	return $files;
}

add_filter('aviate_files', __NAMESPACE__.'\\aviateFiles', 10, 2);