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

HJGreen/silverstripe-laravel-mix

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Silverstripe Laravel Mix

Support for Laravel Mix, including Webpack Hot Module Replacement.

Not recommended for use in production whilst under development.

Usage

This example assumes a theme has been configured and that Laravel Mix is configured to output in the dist/ directory of the theme.

use HJGreen\SilverstripeLaravelMix\Mix;
use SilverStripe\CMS\Controllers\ContentController;
use SilverStripe\Control\Director;
use SilverStripe\View\Requirements;
use SilverStripe\View\ThemeResourceLoader;

class PageController extends ContentController {
    public function init(){
        parent::init();
        
        if (Director::isDev()) {
            Requirements::css(Mix::resolve('/dist/styles.css'));
            Requirements::javascript(Mix::resolve('/dist/index.js'));
        } else {
            $theme = ThemeResourceLoader::inst();
            Requirements::css($theme->findThemedCSS('/dist/styles.css'));
            Requirements::javascript($theme->findThemedJavascript('/dist/index.js'));
        }
    }
}

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages