Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Laravel mix is not properly updating the mix-manifest.json #283

Closed
mlevkovsky opened this issue Feb 3, 2017 · 12 comments
Closed

Laravel mix is not properly updating the mix-manifest.json #283

mlevkovsky opened this issue Feb 3, 2017 · 12 comments

Comments

@mlevkovsky
Copy link

This is my mix file

`const { mix } = require('laravel-mix');

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

However whenever I try to reference my styles.css folder with

<link rel="stylesheet" href="{{ mix('/css/styles.css') }}"/>

I get an error 500 saying: Unable to locate Mix file: /css/styles.css

When I check the mix-manifest.json my styles.css is not added in there. If I add it myself then everything loads fine, but since it's recreated each time I run mix, that's obviously not an option.

Thanks in advance

@iraklisg
Copy link

iraklisg commented Feb 3, 2017

Please have a look into this #284 issue as well. Copying a file is a separate processes from Webpack compilation and files that are not part of the bundle are not included in mix-manifest

@JeffreyWay
Copy link
Collaborator

Yeah, mix.combine() is a plugin that happens after Webpack compiles. But I just pushed a commit that will manually add its output paths to your mix-manifest.json file for convenience. That way, you don't have to worry about it.

@mlevkovsky
Copy link
Author

hey @JeffreyWay that's awesome!
Quick question then. What is the best practice in this case if I want to use a regular css file in my project?
What I did in previous Laravel versions is I created my styles.css in resources/css/ folder,
combined them and copied them over with elixir.

Should I be doing it differently now with mix?

@mlevkovsky
Copy link
Author

@JeffreyWay so I updated to the latest version on github, however my manifest-json still doesn't update.
What I'll do for now with my plain css files, is just copy them over using mix, and then reference them using elixir without using the mix function.

@JeffreyWay
Copy link
Collaborator

JeffreyWay commented Feb 3, 2017

I haven't tagged that commit yet.

If you only want to combine some CSS files, and then minify them for production, you would do this:

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

/*
 |--------------------------------------------------------------------------
 | Mix Asset Management
 |--------------------------------------------------------------------------
 |
 | Mix provides a clean, fluent API for defining some Webpack build steps
 | for your Laravel application. By default, we are compiling the Sass
 | file for your application, as well as bundling up your JS files.
 |
 */

mix.combine([
    'resources/assets/css/one.css', 
    'resources/assets/css/two.css'
], 'public/css/all.css');

With the commit that I just pushed, that will then generate this mix-manifest.json file:

{
  "mix.js": "mix.js",
  "/css/all.css": "/css/all.css"
}

And it will also now watch your source files for changes.

@mlevkovsky
Copy link
Author

Hmm that's what I tried but it didn't really work as the manifest stayed the same.
I'll try again in a bit and let you know.

@JeffreyWay
Copy link
Collaborator

JeffreyWay commented Feb 3, 2017 via email

@mlevkovsky
Copy link
Author

dude A+ on the support and dedication.

@basuregami
Copy link

dude i did the same as you have mention but didnt work for me !! any idea

@brada1703
Copy link

@basuregami - Mine is working on my localhost, but when I push it to the server, I get this error. Any idea?

@vjoao
Copy link

vjoao commented Aug 28, 2017

@brada1703 could you solve it?

@crazyfree
Copy link

@JeffreyWay today i got same problem when including the blueimp-file-upload library into my project.

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

mix
    .js('resources/assets/js/shared/main.js', 'public/js/shared')
    .sass('resources/assets/sass/shared/main.scss', 'public/css/shared')

    // libraries copy
    .copy('node_modules/blueimp-file-upload/js', 'public/blueimp-file-upload/js')
    .copy('node_modules/blueimp-file-upload/css', 'public/blueimp-file-upload/css')
;

and this is my mix-mainfiest.json

{
    "/js/shared/main.js": "/js/shared/main.js",
    "/css/shared/main.css": "/css/shared/main.css",
}

i'm using "laravel-mix": "^4.0.7" with Laravel 5.7
Kindly help. Thanks in advance!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants