wewowweb / laravel-mix-svelte

mix.svelte();
MIT License
68 stars 10 forks source link

Mix 6 compatibility #13

Closed greatislander closed 3 years ago

greatislander commented 3 years ago

I was running into the same issues described in https://github.com/wewowweb/laravel-mix-svelte/issues/11#issuecomment-762116535 and was able to resolve them by replacing mix.config.babel() with the Laravel Mix 6.0 convention of Config.babel(). I also encountered two other errors. The first was as follows:

[webpack-cli] ReferenceError: path is not defined
    at Svelte.webpackConfig (/project/node_modules/laravel-mix-svelte/src/index.js:41:46)

(Line reference: https://github.com/wewowweb/laravel-mix-svelte/blob/master/src/index.js#L41)

When I added path as a dependency, I got this error:

[webpack-cli] TypeError: Cannot set property 'svelte' of undefined
    at Svelte.webpackConfig (/project/node_modules/laravel-mix-svelte/src/index.js:44:44)

(Line reference: https://github.com/wewowweb/laravel-mix-svelte/blob/master/src/index.js#L41)

I used this pattern from the Laravel Mix core Vue extension to ensure that webpackConfig.resolve.alias is defined.

This PR includes all three fixes and appears to work for me. I'm using:

Node: v12.16.3 NPM: 6.14.10 Laravel Mix: 6.0.9

morpheus7CS commented 3 years ago

Hey @greatislander,

thanks for taking the time to do this. Looks good on my end, so I'll merge it in and create a v6-only release.

Kind regards, g