Ad

Laravel 5.2 Elixir

- 1 answer

I am using laravel 5.2 and I've successfully create all.css in public/css folder using gulp.

but when I try to use all.css in view admin.login using following line of code as defined in laravel 5.2 documentation and it not works

<link rel="stylesheet" type="text/css" target="_blank" rel="nofollow noreferrer" href="{{ elixir('css/all.css') }}">

and when I use this following line of code it works.

<link rel="stylesheet" type="text/css" target="_blank" rel="nofollow noreferrer" href="{{ url('/public/' . elixir('css/all.css')) }}">

Is it correct? or I am missing some thing?

Ad

Answer

If you simple put all.css file into public/css location and you want to simply display this file, you can use:

<link rel="stylesheet" target="_blank" rel="nofollow noreferrer" href="{{ asset("css/all.css") }}>

However if you plan to modify this file and you don't want to have caching issues, yo all.css file into public/css location and you want to simply display this file, you can use:

<link rel="stylesheet" target="_blank" rel="nofollow noreferrer" target="_blank" rel="nofollow noreferrer" href="{{ asset("css/all.css") }}>

However if you plan to modify this file and you don't want to have caching issues, you can put this all.css file again into

public/css then write below code into gulpfile.js

var elixir = require('laravel-elixir');

elixir(function(mix) {
    mix.version("public/css/all.css");
});

now you need to run gulp in your console

gulp

Now you can use:

<link rel="stylesheet" target="_blank" rel="nofollow noreferrer" target="_blank" rel="nofollow noreferrer" href="{{ elixir("css/all.css") }}>

This original link will explain better :)

Ad
source: stackoverflow.com
Ad