Tuesday, August 23, 2016

Laravel Elixir Setup and Uses



Laravel Elixir provides a clean, fluent API for defining basic Gulp tasks for your Laravel application. Elixir supports several common CSS and JavaScript pre-processors, and even testing tools. Using method chaining, Elixir allows you to fluently define your asset pipeline. For example:
elixir(function(mix) {
    mix.sass('app.scss')
       .coffee('app.coffee');
});
Gulp is a task/build runner for development. It allows you to do a lot of stuff within your development workflow. You can compile sass files, uglify and compress js files and much more.

Installation & Setting Up

  • First Setup Node
    • Try Following command to check node version
      • node -v 
          
  • Install Gulp Globally
    • Try Following command 
      • npm install --global gulp-cli (for windows)
      • sudo npm install --global gulp-cli (for linux)
      • npm install -- (to install npm dependency: use sudo for linux do install all dependency)
After   Installing all dependency , run following code to notify all changes related to app.scss or any file your are willing to work.







  • gulp watch 
  • Lets say, we want to make change to app.scss and convert it to css file under public folder.
    To do this, first change 
    elixir(function(mix) {
        mix.sass('app.scss')
           .coffee('app.coffee');
    });
    to

    elixir(function(mix) {
        mix.sass('app.scss','public/style.css');
    });
    now change code in app.scss file and you'll see all changes in public/style.css file.

    Related Posts:

    • Up & Running With Gulp Check Older version if installed $ npm rm --global gulp   Install Gulp Globally $ npm install --global gulp-cli Initializing Project directory npm init Installing Dependencies npm install --save-dev gulp Creatng gu… Read More
    • Laravel 5.2 Implicit model binding In Laravel 5.2 new feature called implicit model binding added. Which can be implement efficiently and in a very easy manner. Here how its done : In your routes.php file create a new route Route::get('user',function(){}); … Read More
    • Laravel Project Setup Using Composer In this tutorial i’ll write the key points that are necessary to create a laravel project/setting a laravel project with the help of composer. Composer Setup First We have to understand what is composer? Well, Composer is … Read More
    • Laravel Elixir Setup and Uses Laravel Elixir provides a clean, fluent API for defining basic Gulp tasks for your Laravel application. Elixir supports several common CSS and JavaScript pre-processors, and even testing tools. Using method chaining, … Read More
    • Install LAMP and PHPmyAdmin && PHPpgAdmin on Ubuntu 14.04 Install LAMP Steps are: sudo apt-get update sudo apt-get install apache2 sudo apt-get install mysql-server php5-mysql sudo apt-get install php5 libapache2-mod-php5 php5-mcrypt sudo gedit /etc/apache2/conf-available/serve-… Read More

    1 comment:

    1. This is great content. You've loaded this with useful, informative content that any reader can understand. I enjoy reading articles that are so very well-written. elixir definition Define Dictionary Meaning. A simple vocabulary sharing platform. Dedicated to learn and share knowledge by defining words and concepts in short and easy English. Define your own words and their meanings.

      ReplyDelete