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-wiredep

v2.1.0

Published

Laravel Elixir Wiredep extension

Downloads

117

Readme

#Laravel-Elixir-Wiredep

This is a simple wrapper around Laravel Elixir for Wiredep.

npm npm

Getting Started

Install the module with npm:

laravel-elixir >v3.x

$ npm install --save-dev laravel-elixir-wiredep

laravel-elixir < v2.x

$ npm install --save-dev [email protected]

And add it to your Elixir-enhanced Gulpfile, like so:

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

require('laravel-elixir-wiredep');

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

Then you just have to edit your php file(s) and some extra markup, like this:

<!doctype html>
<html>
<head>
	<meta charset="utf-8">

	<!-- bower:css -->
	<!-- endbower -->
</head>
<body>
	<!-- bower:js -->
	<!-- endbower -->
</body>
</html>

This will scan your Bower dependencies on bower.json and inject them all in your .php files inside resources/views/ directory. Instead, if you only want to inject dependencies on a single file, you may do:

mix.wiredep({src: 'master.blade.php'})

If you run $ gulp watch this will also watch your bower.json for any changes and inject them automatically. Whenever you install a new bower package with the -S flag your php files will be updated.

NOTE

Since Wiredep serves bower components, these must inside the public folder. Just create a .bowerrc file in the root of your project folder and specify the destination folder inside the public folder, like so:

{
  "directory" : "public/bower_components"
}

Options

This wrapper accepts three optional parameters with configurations:

mix.wiredep(type, config, opts);
  • type - a string with the type of file 'php','sass','scss','less'
  • config - an object with the configs for the laravel-elixir-wiredep package
  • opts - an object with the configs for the wiredep package, you can get more info about it here

These are the default wrapper options and the default wiredep options for each type of file:

sass: {
  config: {
    baseDir: 'resources/assets/sass',
    src: false,
    searchLevel: '**/*.sass'
  },
  opts: {
    ignorePath: ''
  }
},
scss: {
  config: {
    baseDir: 'resources/assets/sass',
    src: false,
    searchLevel: '**/*.scss'
  },
  opts: {
    ignorePath: ''
  }
},
less: {
  config: {
    baseDir: 'resources/assets/less',
    src: false,
    searchLevel: '**/*.less'
  },
  opts: {
    ignorePath: ''
  }
},
php: {
  config: {
    baseDir: 'resources/views/',
    src: false,
    searchLevel: '**/*.php'
  },
  opts: {
    ignorePath: /(\..\/)*(public)?/,
    fileTypes: {
      php: {
        block: /(([ \t]*)<!--\s*bower:*(\S*)\s*-->)(\n|\r|.)*?(<!--\s*endbower\s*-->)/gi,
        detect: {
          js: /<script.*src=['"]([^'"]+)/gi,
          css: /<link.*href=['"]([^'"]+)/gi
        },
        replace: {
          js: '<script src="{{filePath}}"></script>',
          css: '<link rel="stylesheet" href="{{filePath}}" />'
        }
      }
    }
  }
}

You can override the default options, by just passing them as second and third options or in case of PHP files you can omit the first parameter type and just pass the options.

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

elixir(function(mix) {
    mix.wiredep('php',{ src: 'master.blade.php' }, { ignorePath: null } );
    //if your first parameter is php you can omit it and achieve the same result
    mix.wiredep({ src: 'master.blade.php' }, { ignorePath: null } );
});

Examples

PHP

Wiredep one PHP file

This is an example of a Gulp file that Wiredeps only your javascript and CSS dependencies into the resources/views/master.blade.php:

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

elixir(function(mix) {
    mix.wiredep({src: 'master.blade.php'});
});

Wiredep multiple PHP files

This is an example of a Gulp file that Wiredeps only your javascript and CSS dependencies into all the PHP files, inside the resources/views/ folder, that have the bower tags:

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

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

Styles

Scss

This one is an example of a Gulp file that Wiredeps only your scss dependencies into your Scss file and compiles it into the public/css/app.css:

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

elixir(function(mix) {
    mix.wiredep('scss')
    .sass('app.scss');
});

On your app.scss just add the bower comments.

// bower:scss
// endbower
@import "someLocalScssFile";

$white: #ffffff;
$black: #000000;

Sass

This one is an example of a Gulp file that Wiredeps only your sass dependencies and compiles your Sass file into the public/css/app.css:

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

elixir(function(mix) {
    mix.wiredep('sass')
    .sass('app.sass');
});

On your app.sass just add the bower comments.

// bower:sass
// endbower
@import "someLocalSassFile";

$white: #ffffff;
$black: #000000;

Less

This one is an example of a Gulp file that Wiredeps only your less dependencies and compiles your Less file into the public/css/app.css:

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

elixir(function(mix) {
    mix.wiredep('less')
    .less('app.less');
});

On your app.less just add the bower comments.

// bower:less
// endbower
@import "someLocalSassFile";

$white: #ffffff;
$black: #000000;

Multiple Wiredeps

If you want to Wiredep your sass/scss/less styles and also Wiredep Javascript and/or css into your PHP files, you just have to Wiredep twice.

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

elixir(function(mix) {
    mix.wiredep('scss')
    .sass('app.scss')
    .wiredep();
});