moyus / laravel-mix-nunjucks

Laravel Mix extension to compile Nunjucks templates
MIT License
11 stars 5 forks source link

Path problems on Windows #10

Closed Niksac closed 2 years ago

Niksac commented 2 years ago

When using Windows, Nunjuck files will not compile unless in "watch" mode. I tracked down the issue to be caused by the globby package which does not match for windows paths with backslashes.

Using this.from.path().replace(/\\/g, '/') as pattern for globby, will work as a workaround until the folks at globby fix it on their end.

What do you think?

moyus commented 2 years ago

Didn't have a Windows computer to test such case, I will fix it in the next update version soon.

moyus commented 2 years ago

@Niksac I have published a beta version laravel-mix-nunjucks@1.2.0-beta.1, could you please help me test whether it works now?

Niksac commented 2 years ago

With your beta version, the Windows path issue is gone.

However, I needed to update the laravel-mix package because the laravel-mix/src/components/Component.js file, you now use in index.js was not present in my laravel-mix version (6.0.25).

The file is marked as @internal by the mix devs, so I would advise against referencing it for now. Alternatively, the package.json should be upgraded to the new requirements.

moyus commented 2 years ago

Try laravel-mix-nunjucks@1.2.0-beta.2, I think it could be the candidate release version.

Niksac commented 2 years ago

Not working for me: [webpack-cli] TypeError: Class constructor Nunjucks cannot be invoked without 'new'

Passing an instance when extending fixed it for me: mix.extend("njk", new Nunjucks);

moyus commented 2 years ago

Looks it's the last issue I need to fix.

moyus commented 2 years ago

v1.2.0 has been published, the issue should be resolved.

Niksac commented 2 years ago

v1.2.0 seems to work without issue on windows. Thank you!