I've created a src folder within a WordPress themes directory for all build scripts, node modules, etc (so I can hide it when publishing to the server).
In that folder I have webpack.mix.js:
mix.sass('sass/style.scss', '../style.css')
.js('js/script.js', '../script.js')
This publishes the style.css in the themes (parent) directory as required, but when I do the same for the script.js file it publishes it in the current src folder but creates a list of all folders from my system Users directory Users/jackbarham/Code/etc/.../etc/theme/src/script.js all the way to the output file.
I've tried altering paths, but I can't get it to work or understand why it's working for CSS but not JS.
Hello,
same issue here.
have you found a sollution yet?
No, I haven't yet. Please let me know if you do.
Can you try
mix.sass('sass/style.scss', './../style.css')
.js('js/script.js', './../script.js')
Otherwise, you might have to specify the path from root.
I've tried that already and get exactly the same output. CSS is correct but not JS.
As a side note: I was previously using Laravel Elixir (a different package, I know) but that compiled both assets into the correct folder using the same path as above.
Try replacing
.js() with .scripts()
and see if it worked.
Yes! That's worked :)
Doesn't seem to work for .copy() though. -.-
I am experiencing the same behaviour. Even though the "chunk name" appears to be correct, the whole destination path gets replicated into the folder where I run the script.
Neither relative or absolute filesystem path fixes the problem for me unfortunately.
However, copy and sass command work as expected.
Same problem here.
I have the same problem - this seems like a good work around for the time being: https://github.com/JeffreyWay/laravel-mix/issues/174#issuecomment-275256893
This worked for me: mix.setPublicPath('../parent-folder/');
I did sth like that and it's working.
mix.setPublicPath('../')
.js('resources/assets/js/app.js', 'js')
.sass('resources/assets/sass/app.scss', 'css');
thanks @eliamariutti , your solution was the good one for me !
Most helpful comment
I did sth like that and it's working.
mix.setPublicPath('../') .js('resources/assets/js/app.js', 'js') .sass('resources/assets/sass/app.scss', 'css');