Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

globally/static config eg set default path? #2

Open
codemonkeynorth opened this issue May 27, 2022 · 2 comments
Open

globally/static config eg set default path? #2

codemonkeynorth opened this issue May 27, 2022 · 2 comments

Comments

@codemonkeynorth
Copy link

codemonkeynorth commented May 27, 2022

Hi,

it'd be useful to be able to globally set the path to something other than build so it doesn't need to be called every time I call mix

I will probably be using it a lot in my templates, but my files are in dist, so ideally I could configure this in my bootstrap functions

<script src="{{ mix('js/app.js') }}"></script>
<link rel="stylesheet" href="{{ mix('css/app.css')" />

also it would be good if you could namespace your class/methods to Mindkomm maybe?

anyway in the meantime I've done it like this (adding the namespace to your file):

public function add_to_twig( $twig ) {
    $twig->addFunction( new \Timber\Twig_Function( 'mix', [$this, 'mix']));
    return $twig;
}

public function mix($path) {
    return \Mindkomm\mix($path, ['manifest_directory' => 'dist']);
}

hope that's useful to somebody.

@gchtr
Copy link
Member

gchtr commented Jun 3, 2022

it'd be useful to be able to globally set the path to something other than build so it doesn't need to be called every time I call mix

You can already do that using the theme/mix/args/defaults filter:

functions.php

add_filter( 'theme/mix/args/defaults', function( $defaults ) {
    $defaults['manifest_directory'] = 'dist';

    return $defaults;
} );

also it would be good if you could namespace your class/methods to Mindkomm maybe?

I’ll consider that for the future. Namespacing surely is a good idea in WordPress land.

@codemonkeynorth
Copy link
Author

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants