Skip to content
This repository has been archived by the owner on May 28, 2024. It is now read-only.

weprovide/aviate-wordpress

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Aviate WordPress

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);

About

Aviate implementation for WordPress

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages