Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change webpack path to an upper directory(root) in Laravel?

Due to security reasons I move all directories and files into a main directory and took out all files/directories from public folder to root of Laravel project. Now I want to npm run dev in order to compile scss files to css and js to js. However each time I run npm run dev it creates a folder named public inside the main folder I had created and put compiled files into that. But I want to put it in root folder which contains: css-js-svg-fonts-index so I changed

This:

mix.js('resources/js/app.js', 'public/js')
    .sass('resources/sass/app.scss', 'public/css');

to this:

mix.js('resources/js/app.js', '../../js')
    .sass('resources/sass/app.scss', '../../css');

but no result :( it just creates public folder inside main folder that is not the root I want it to be one level upper.

Thanks

like image 509
kodfire Avatar asked Nov 05 '25 02:11

kodfire


1 Answers

I found it :)

mix.setPublicPath('../')
    .js('resources/js/app.js', 'js')
    .sass('resources/sass/app.scss', 'css');

but previously I was wrong with an extra slash which was:

mix.setPublicPath('../')
    .js('resources/js/app.js', '/js')
    .sass('resources/sass/app.scss', '/css');
like image 67
kodfire Avatar answered Nov 06 '25 16:11

kodfire



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!