06.10.2016 Views

laravel-5

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Laravel Elixir 328<br />

Source Maps<br />

Source maps are enabled out of the box. So, for each file that is compiled you will find a companion<br />

*.css.map file in the same directory. This mapping allows you to trace your compiled stylesheet<br />

selectors back to your original Sass or Less while debugging in your browser.<br />

If you do not want source maps generated for your CSS, you may disable them using a simple<br />

configuration option:<br />

1 elixir.config.sourcemaps = false;<br />

2<br />

3 elixir(function(mix) {<br />

4 A> mix.sass('app.scss');<br />

5<br />

6 });<br />

Working With Scripts<br />

Elixir also provides several functions to help you work with your JavaScript files, such as compiling<br />

ECMAScript 6, compiling CoffeeScript, Browserify, minification, and simply concatenating plain<br />

JavaScript files.<br />

CoffeeScript<br />

The coffee method may be used to compile CoffeeScript¹⁷⁵ into plain JavaScript. The coffee<br />

function accepts a string or array of CoffeeScript files relative to the resources/assets/coffee<br />

directory and generates a single app.js file in the public/js directory:<br />

1 elixir(function(mix) {<br />

2 A> mix.coffee(['app.coffee', 'controllers.coffee']);<br />

3<br />

4 });<br />

Browserify<br />

Elixir also ships with a browserify method, which gives you all the benefits of requiring modules<br />

in the browser and using ECMAScript 6 and JSX.<br />

This task assumes that your scripts are stored in resources/assets/js and will place the resulting<br />

file in public/js/main.js. You may pass a custom output location as an optional second argument:<br />

¹⁷⁵http://coffeescript.org/

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!