2017 © Pedro Peláez
 

library aviate-magento2

Aviate implementation for Magento 2

image

weprovide/aviate-magento2

Aviate implementation for Magento 2

  • Friday, February 23, 2018
  • by timneutkens
  • Repository
  • 2 Watchers
  • 0 Stars
  • 4,293 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 7 Versions
  • 42 % Grown

The README.md

Aviate Magento 2

Aviate implementation for Magento 2., (*1)

Installation

composer require weprovide/aviate-magento2

Configuration

const path = require('path')

// NAMESPACE/THEME Needs to match your exact theme namespace and name. Since the module will automatically load NAMESPACE/THEME.css
module.exports = {
    // For production we expect the assets to be in web/dist
    distLocations: [
        path.join(__dirname, 'app/design/frontend/NAMESPACE/THEME/web/dist')
    ],
    decorateConfig(config) {
        config.entry = Object.assign({}, config.entry, {
            'NAMESPACE/THEME': [
                path.join(__dirname, 'app/design/frontend/NAMESPACE/THEME/styles/styles.scss')
            ]
        })

        // Allows you to use relative paths to theme in your CSS and Javascript. For SASS you can use @import "~theme/path/to/file"
        config.resolve = {
            alias: {
                theme: path.join(__dirname, 'app/design/frontend/NAMESPACE/THEME')
            }
        }

        return config
    }
}

Adding custom files

In some cases you'll want to add custom files. For example a React application. You can achieve this using Magento 2 Interceptors., (*2)

aviate.config.js (in project root):, (*3)

const path = require('path')

// NAMESPACE/THEME Needs to match your exact theme namespace and name. Since the module will automatically load NAMESPACE/THEME.css
module.exports = {
    // For production we expect the assets to be in web/dist
    distLocations: [
        path.join(__dirname, 'app/design/frontend/NAMESPACE/THEME/web/dist')
    ],
    decorateConfig(config) {
        config.entry = Object.assign({}, config.entry, {
            'NAMESPACE/THEME': [
                path.join(__dirname, 'app/design/frontend/NAMESPACE/THEME/styles/styles.scss')
            ],
            // This part is the custom file
            'NAMESPACE/THEME/react': [
                'react-hot-loader/patch',
                path.join(__dirname, 'app/design/frontend/NAMESPACE/THEME/react/app.js'),
            ]
        })

        // Allows you to use relative paths to theme in your CSS and Javascript. For SASS you can use @import "~theme/path/to/file"
        config.resolve = {
            alias: {
                theme: path.join(__dirname, 'app/design/frontend/NAMESPACE/THEME')
            }
        }

        return config
    }
}

etc/di.xml:, (*4)

<?xml version="1.0" ?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
    <type name="WeProvide\Aviate\Magento2\Block\DevServer">
        <plugin disabled="false" name="Add_React" sortOrder="10" type="NAMESPACE\MODULE\Plugin\AddReact"/>
    </type>
</config>

Plugin/AddReact.php:, (*5)

<?php

namespace NAMESPACE\MODULE\Plugin;

use WeProvide\Aviate\Magento2\Block\DevServer;

class AddReact
{
    public function afterGetFiles(
        DevServer $subject,
        $types
    ) {
        $aviate = $subject->aviate();
        $themePath = $aviate->getTheme()->getThemePath();

        if ($aviate->isDevMode()) {
            $types['js'][] = $aviate->getDevServerUrl($themePath . '/react.js');

            return $types;
        }

        $types['js'][] = $subject->getViewFileUrl('dist/' . $themePath . '/react.js');

        return $types;
    }
}

The Versions

23/02 2018

dev-master

9999999-dev

Aviate implementation for Magento 2

  Sources   Download

MIT

The Requires

 

by Tim Neutkens

23/02 2018

1.0.0

1.0.0.0

Aviate implementation for Magento 2

  Sources   Download

MIT

The Requires

 

by Tim Neutkens

02/11 2017

0.0.5

0.0.5.0

Aviate implementation for Magento 2

  Sources   Download

MIT

The Requires

 

by Tim Neutkens

20/10 2017

0.0.4

0.0.4.0

Aviate implementation for Magento 2

  Sources   Download

MIT

The Requires

 

by Tim Neutkens

20/09 2017

0.0.3

0.0.3.0

Aviate implementation for Magento 2

  Sources   Download

MIT

The Requires

 

by Tim Neutkens

20/09 2017

0.0.2

0.0.2.0

Aviate implementation for Magento 2

  Sources   Download

MIT

The Requires

 

by Tim Neutkens

06/09 2017

0.0.1

0.0.1.0

Aviate implementation for Magento 2

  Sources   Download

MIT

The Requires

 

by Tim Neutkens