Laravel-mix: Compiling to the root directory instead of public

Created on 25 Jan 2017  路  1Comment  路  Source: JeffreyWay/laravel-mix

I am running a Laravel instance in an environment where OpenBaseDir is enabled such that PHP execution cannot traverse up from the index.php script. As such, the Laravel installation has been modified to move the public directory into the root and operate from there, with some additional server-level permissions to prevent web-access outside the index.php file and a dist directory.

Yes, it's better to use the public directory as intended; yes, there are security concerns in not doing it that way; no, I can't do it that way due to environment restrictions.

Previously using laravel-elixir, I was able to specify the output directories to dist/js and dist/css; however, when I try the same thing with laravel-mix, it creates the public directory and puts a new dist directory under that with the js and css directories.

Is there a way in laravel-mix to have the output in a folder off the root, rather than being forced to use public? Below are samples of what used to work correctly in elixr vs what does not work in mix.

elixr

elixir(mix => {
    mix.sass(['app.scss'], 'dist/css/app.css')
       .webpack(['app.js'], 'dist/js/app.js');
});

Output:

dist/js/app.js
dist/css/app.css
index.php

mix

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

Output:

public/dist/js/app.js
public/dist/css/app.css
public/mix-manifest.json
index.php

Most helpful comment

Nevermind, found this: mix.setPublicPath('dist/');

>All comments

Nevermind, found this: mix.setPublicPath('dist/');

Was this page helpful?
0 / 5 - 0 ratings

Related issues

rlewkowicz picture rlewkowicz  路  3Comments

Bomavi picture Bomavi  路  3Comments

dtheb picture dtheb  路  3Comments

Cheddam picture Cheddam  路  3Comments

amin101 picture amin101  路  3Comments