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
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
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.
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?
@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.
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.
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.
I just tagged it five minutes ago.
On Fri, Feb 3, 2017 at 3:12 PM Mikhail Levkovsky notifications@github.com
wrote:
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.—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/JeffreyWay/laravel-mix/issues/283#issuecomment-277350135,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AALLt4KprtsuyzmfRw7X0YoyOoroerfIks5rY4oWgaJpZM4L2CxQ
.
dude A+ on the support and dedication.
dude i did the same as you have mention but didnt work for me !! any idea
@basuregami - Mine is working on my localhost, but when I push it to the server, I get this error. Any idea?
@brada1703 could you solve it?
@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!
Most helpful comment
@basuregami - Mine is working on my localhost, but when I push it to the server, I get this error. Any idea?