npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

laravel-elixir-plain

v0.0.1

Published

Laravel Elixir Core For Without Ingridients

Downloads

13

Readme

Laravel Elixir

Introduction

Laravel Elixir provides a clean, fluent API for defining some basic Gulp tasks for your Laravel application. Elixir supports several common CSS, JavaScript and even testing tools!

Installation & Setup

Installing Node

Before triggering Elixir, you must first ensure that Node.js is installed on your machine.

node -v

By default, Laravel Homestead includes everything you need; however, if you aren't using Vagrant, then you can easily install Node by visiting nodejs.org, and clicking install. Don't worry, it's quick and easy!

Gulp

Next, you'll want to pull in Gulp globally, like so:

npm install --global gulp

Laravel Elixir

The only remaining step is to install Elixir! With a new install of Laravel, you'll find a package.json file in the root. You may install the dependencies it references by running:

npm install

Usage

Now that you've installed Elixir, you'll be compiling, concatenating, and watching in no time!

Compile Less

elixir(function(mix) {
    mix.less("bootstrap.less");
});

Compile Sass

elixir(function(mix) {
    mix.sass("bootstrap.scss");
});

Compile CoffeeScript

elixir(function(mix) {
    mix.coffee();
});

Compile All Less and CoffeeScript

elixir(function(mix) {
    mix.less()
       .coffee();
});

Trigger PHPUnit Tests

elixir(function(mix) {
    mix.phpUnit();
});

Trigger PHPSpec Tests

elixir(function(mix) {
    mix.phpSpec();
});

Combine Stylesheets

elixir(function(mix) {
    mix.styles([
        "css/normalize.css",
        "css/main.css"
    ]);
});

Combine Scripts

elixir(function(mix) {
    mix.scripts([
        "js/jquery.js",
        "js/app.js"
    ]);
});

Combine Multiple Sets of Scripts

elixir(function(mix) {
    mix.scripts(['js/jquery.js', 'js/main.js'])
       .scripts(['js/forum.js', 'js/threads.js']);
});

Version/Hash a File

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

This will append a unique hash to the filename, allowing for cache-busting. Perhaps something like: all-16d570a7.css.

Within your views, you may use the elixir() function to load the appropriately hashed asset. Here's an example:

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

Behind the scenes, the elixir() function will determine the name of the hashed file that should be included.

Scan For Routes

elixir(function(mix) {
    mix.routes();
});

This will automatically monitor your controllers for changes (and route annotations), and re-generate the cached routes file. The same is true for events.

Scan For Events

elixir(function(mix) {
    mix.events();
});

Put It All Together

elixir(function(mix) {
    mix.less("bootstrap.less")
       .coffee()
       .phpUnit()
       .version("css/bootstrap.css")
       .routes()
       .events();
});

Gulp

Now that you've told Elixir which tasks to execute, you only need to trigger Gulp from the command line.

Execute All Registered Tasks Once

gulp

Watch Assets for Changes

gulp watch

Watch Tests and PHP Classes for Changes

gulp tdd

Note: All tasks will assume a development environment, and will exclude minification. For production, use gulp --production.

Extensions

You can even create your own Gulp tasks, and hook them into Elixir. Imagine that you want to add a fun task that uses the Terminal to verbally notify you with some message. Here's what that might look like:

 var elixir = require("laravel-elixir");
 var gulp = require("gulp");
 var shell = require("gulp-shell");

 elixir.extend("message", function(message) {

     gulp.task("say", function() {
         gulp.src("").pipe(shell("say " + message));
     });

     return this.queueTask("say");

 });

Notice that we extend Elixir's API by passing the key that we will use within our Gulpfile, as well as a callback function that will create the Gulp task.

If you want your custom task to be monitored, then register a watcher as well.

this.registerWatcher("message", "**/*.php");

This lines designates that when any file that matches the regex, **/*.php is modified, we want to trigger the message task.

That's it! You may either place this at the top of your Gulpfile, or instead extract it to a custom tasks file. If you choose the latter approach, simple require it into your Gulpfile, like so:

require("./custom-tasks")

You're done! Now, you can mix it in.

elixir(function(mix) {
    mix.message("Tea, Earl Grey, Hot");
});

With this addition, each time you trigger Gulp, Picard will request some tea.

Available Extension

You'll find a number of Elixir extensions at npmjs.org, under the "laravel-elixir-*" namespace.