How can I change the public path to something containing an underscore in Laravel Mix?

这一生的挚爱 提交于 2019-12-04 23:11:39

There is an undocumented (I believe) method called setPublicPath. You can then omit the public path from the output. setPublicPath plays nicely with underscores.

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

In Laravel 5.5 I've solved like this,

mix.setPublicPath('public_html/')
    .js('resources/assets/js/app.js', 'front/js')
    .js('resources/assets/js/custom.js', 'front/js')
   .sass('resources/assets/sass/app.scss', 'front/css')
   .styles('resources/assets/css/custom.css', 'public_html/front/css/custom.css');

In Laravel 5.4 you can us this code:

in AppServiceProvider :

public function register()
{

    $this->app->bind('path.public', function () {
        return base_path() . DIRECTORY_SEPARATOR .'public_html';
    });

}

In Laravel 5.8

mix.config.publicPath='public_html';
mix.js('resources/assets/js/app.js', 'public_html/js')
   .sass('resources/assets/sass/app.scss', 'public_html'/css');
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!