Laravel-mix: Laravel mix compiles in a duplicate path for js and different path for css.

Created on 23 Jul 2017  路  4Comments  路  Source: JeffreyWay/laravel-mix

  • Laravel Mix Version: v1.30
  • Node Version: v8.2.1
  • NPM Version: v5.3.0
  • OS: CentOS Linux release 7.3.1611 (Core)

Description:

On a fresh Laravel 5.4 installation, when I run npm run dev I get:

/vagrant/projectname/public/vagrant/projectname/public/js/app.js   1.12 MB       0  [emitted]  [big]  /vagrant/projectname/public/vagrant/projectname/public/js/app

../../../vagrant/projectname//css/app.css  75 bytes       0  [emitted]         /vagrant/projectname/public/vagrant/projectname/public/js/app

Instead of getting:

/vagrant/projectname/public/js/app.js   1.12 MB
/vagrant/projectname/public/css/app.css  75 bytes

Also If you notice, css is getting compiled in a different location, I wonder why and how to fix both of these issues, the repeated path for js and the different location for css.

Here's my webpack.mix.js(It's the default that comes with a fresh Laravel installation):

let mix = require('laravel-mix');

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

Steps To Reproduce:

1- Fresh Laravel 5.4 Installation
2- sudo npm install
3- npm run dev
4- Something worth mentioning is that my project root is at /vagrant/projectname, but Laravel-mix is trying to read webpack.mix.js from /home/vagrant/projectname/webpack.mix(two completely different paths), I didn't know how to change from where Mix reads the webpack.mix file, so I copied webpack.mix.js from project root to the latter destination just to get things to work, then I hit the above issue.

All 4 comments

Yeah I'm getting this with 1.2.2:
image

dist/css is empty.

@Yugis -

Something worth mentioning is that my project root is at /vagrant/projectname, but Laravel-mix is trying to read webpack.mix.js from /home/vagrant/projectname/webpack.mix(two completely different paths), I didn't know how to change from where Mix reads the webpack.mix file, so I copied webpack.mix.js from project root to the latter destination just to get things to work, then I hit the above issue.

This is very likely what's causing the issue. Moving the file is causing the file path normalizing to screw up.

The thing is I managed to change the path from which Laravel-Mix reads the file, It's now reading the proper file at the proper destination, but the output path is was still messed up, but thanks for the clarification.

Nothing changed about my setup, yet I still get this problem with 1.2.2 both on my dev and production environments. Reverting back to 0.12.1 has fixed it for me.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

terion-name picture terion-name  路  3Comments

wendt88 picture wendt88  路  3Comments

jpriceonline picture jpriceonline  路  3Comments

mementoneli picture mementoneli  路  3Comments

stefensuhat picture stefensuhat  路  3Comments