All Projects → venveo → craft-elixir

venveo / craft-elixir

Licence: MIT license
Craft Plugin that allows you to use Laravel's Elixir in Craft templates

Programming Languages

PHP
23972 projects - #3 most used programming language
HTML
75241 projects

Projects that are alternatives of or similar to craft-elixir

overflow.craft-plugin
A plain text Craft field type, with a soft or hard character limit.
Stars: ✭ 13 (-13.33%)
Mutual labels:  craft, craftcms
craft-json-snippets
Helps make CraftCMS models in .json
Stars: ✭ 17 (+13.33%)
Mutual labels:  craft, craftcms
craft3-collections
Clean up those complex templates with Laravel Collections
Stars: ✭ 24 (+60%)
Mutual labels:  craft, craftcms
Linkit
Multi-purpose link plugin for Craft CMS
Stars: ✭ 155 (+933.33%)
Mutual labels:  craft, craftcms
craft-entry-instructions
A simple fieldtype to add instructions.
Stars: ✭ 16 (+6.67%)
Mutual labels:  craft, craftcms
Seo
SEO utilities including a unique field type, sitemap & redirect manager
Stars: ✭ 210 (+1300%)
Mutual labels:  craft, craftcms
craft-twig
Craft CMS Package for Atom
Stars: ✭ 17 (+13.33%)
Mutual labels:  craft, craftcms
Craft Preparse Field
Field type that parses twig when an element is saved.
Stars: ✭ 103 (+586.67%)
Mutual labels:  craft, craftcms
tablemaker
A user-definable table field type for Craft CMS
Stars: ✭ 39 (+160%)
Mutual labels:  craft, craftcms
webmention
Webmention Plugin for Craft CMS
Stars: ✭ 38 (+153.33%)
Mutual labels:  craft, craftcms
Craft Cli
Command line interface for Craft CMS 2.
Stars: ✭ 143 (+853.33%)
Mutual labels:  craft, craftcms
craftbox
Simple Ubuntu Vagrant box targeted for Craft developers -
Stars: ✭ 28 (+86.67%)
Mutual labels:  craft, craftcms
Simplemap
A beautifully simple map field type for Craft CMS.
Stars: ✭ 136 (+806.67%)
Mutual labels:  craft, craftcms
craft-cpbodyclasses
Control Panel Body Classes plugin for Craft CMS
Stars: ✭ 24 (+60%)
Mutual labels:  craft, craftcms
Craft Cpcss
Control Panel CSS plugin for Craft CMS
Stars: ✭ 115 (+666.67%)
Mutual labels:  craft, craftcms
smartdown.craft-plugin
Bringing the unbridled joy of Markdown Extra and Smartypants to your Craft websites.
Stars: ✭ 26 (+73.33%)
Mutual labels:  craft, craftcms
Buttonbox
A collection of utility field types for Craft
Stars: ✭ 94 (+526.67%)
Mutual labels:  craft, craftcms
Craftcms Docker
Craft3/Craft2 CMS Docker base (Nginx, PHP-FPM 8, PostgreSQL/MariaDB, Redis)
Stars: ✭ 99 (+560%)
Mutual labels:  craft, craftcms
craft-audit
Audit log for Craft 3
Stars: ✭ 18 (+20%)
Mutual labels:  craft, craftcms
oembed
A simple plugin to extract media information from websites, like youtube videos, twitter statuses or blog articles.
Stars: ✭ 34 (+126.67%)
Mutual labels:  craft, craftcms

Use Laravel Elixir with Craft CMS

You can already use Laravel Elixir with Craft. It's rather straight forward. In fact, Matt Stauffer has an excellent write up on using Elixir on his company blog.

However, when using a CDN such as CloudFlare or Fastly. You might want to take advantage of file versioning to bust the cache. This plugin lets you use Elixir's built in versioning in your Craft templates!

Requirements

npm

Installation and Setup

If you haven't read the Elixir documentation on the Laravel website or the blog post above, Here is a quick overview on setting up Elixir.

create a package.json with the following content:

{
  "private": true,
  "devDependencies": {
    "gulp": "^3.9.1"
  },
  "dependencies": {
    "laravel-elixir": "^5.0.0"
  }
}

run the npm install command:

npm install

add your SCSS, JavaScript and etc just like a Laravel project under resources/assets/sass and resources/assets/js.

create a gulpfile.js with your contents or copy this one:

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

elixir(function(mix) {
    mix.sass('app.scss')
        .version('css/app.css');
});

Run gulp watch!

When using the Elixir version function your CSS/JavaScript will output to public/css/all-16d570a7.css. This is where this plugin comes in!

Usage

With Laravel there is an Elixir PHP helper function that retrieves the correct version. Now you can do this in Craft templates!

Twig Function

{{ elixir('css/all.css') }}

Note: you can optionally output the entire HTML tag by passing a second argument true to the function (e.g {{ elixir('css/all.css', true) }}.

Twig Filter

{{ 'css/all.css' | elixir }}

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

and

<script src="{{ craft.elixir.version('js/app.js') }}"></script>

If you are especially lazy, you can have the plugin automatically create the entire tag, based on the file extension.

{{ craft.elixir.withTag('js/app.js') | raw }}

This will output the <script> or <link> tags appropriately.

Credits

About Venveo

Venveo is a Digital Marketing Agency for Building Materials Companies in Blacksburg, VA. Learn more about us on our website.

License

The MIT License (MIT). Please see License File for more information.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].