42
Mixing Up the Front-end with ColdBox Elixir

ITB2016 - Mixing up the front end with ColdBox elixir

Embed Size (px)

Citation preview

Page 1: ITB2016 - Mixing up the front end with ColdBox elixir

Mixing Up the Front-end with ColdBox Elixir

Page 2: ITB2016 - Mixing up the front end with ColdBox elixir

What this talk isn't4 For people with a highly specific build tool / chain

4 For people who never start any new projects

4 About ES6, Babel, Sass, or any of the other tasks in our build chain

Page 3: ITB2016 - Mixing up the front end with ColdBox elixir

What this talk is4 Quick, simple, out-of-the-box front-end builds

4 Builds specific to ColdBox

4 An overview of the latest *Box product

Page 4: ITB2016 - Mixing up the front end with ColdBox elixir

Other Session Right Now4 AWS Lambda — what, why, when, how?

Box Room

Page 5: ITB2016 - Mixing up the front end with ColdBox elixir

Who am I?Eric Peterson

! Utah

" O.C. Tanner

# 1 wife, 1 kid

Page 6: ITB2016 - Mixing up the front end with ColdBox elixir

Front-end Builds

4 Grunt

4 Gulp

4 Webpack

4 NPM Scripts

4 ???

Page 7: ITB2016 - Mixing up the front end with ColdBox elixir
Page 8: ITB2016 - Mixing up the front end with ColdBox elixir

Every New Project

Page 9: ITB2016 - Mixing up the front end with ColdBox elixir

Every New Project

4 Decide if you are going to keep your same source and destination path conventions

4 Create all the folders you need

4 Wire up your front-end build with your decided-upon conventions

Page 10: ITB2016 - Mixing up the front end with ColdBox elixir

Every New Project

4 Write a crazy gulpfile.js

4 Bang your head against the wall remembering weird gulp syntax

4 Hope that copy and pasting your config from a previous project won't be worse

Page 11: ITB2016 - Mixing up the front end with ColdBox elixir

Introducing ColdBox ElixirInspired from Laravel Elixir

Page 12: ITB2016 - Mixing up the front end with ColdBox elixir

// gulpfile.js

var elixir = require( "coldbox-elixir" );

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

Page 13: ITB2016 - Mixing up the front end with ColdBox elixir

That's it!

Page 14: ITB2016 - Mixing up the front end with ColdBox elixir

Convention over Configuration

Page 15: ITB2016 - Mixing up the front end with ColdBox elixir

ColdBox Elixir knows about your ColdBox project

You don't have to specify the conventions!

Page 16: ITB2016 - Mixing up the front end with ColdBox elixir

Default ColdBox Conventions4 Javascript

4 /resources/assets/js => /includes/js

4 CSS

4 /resources/assets/css => /includes/css

Page 17: ITB2016 - Mixing up the front end with ColdBox elixir

Standard Elixir Task Format

elixir( function( mix ){ mix.styles( /* source filename */, /* override the destination folder */, /* override the source folder */ );} );

Page 18: ITB2016 - Mixing up the front end with ColdBox elixir

Yes, the source and destination folders can be overridden

But just stick to the conventions

It makes your life so much easier!

Page 19: ITB2016 - Mixing up the front end with ColdBox elixir

Styles

Page 20: ITB2016 - Mixing up the front end with ColdBox elixir

Styles • Pre-processors

elixir( function( mix ){ // ./resources/sass/app.scss mix.sass( "app.scss" ); // OR // ./resources/less/app.less mix.less( "app.less" );} );

Page 21: ITB2016 - Mixing up the front end with ColdBox elixir

Styles • Pre-processors

elixir( function( mix ){ mix.sass( [ "app.scss", "bootstrap.sass" ] ); // ./includes/css/app.css} );

Page 22: ITB2016 - Mixing up the front end with ColdBox elixir

Styles • Combining Stylesheets

elixir( function( mix ){ mix.styles( [ "vendor/normalize.css", "vendor/bootstrap.min.css", "app.css" ] ); // ./includes/css/all.css} );

Page 23: ITB2016 - Mixing up the front end with ColdBox elixir

Javascript

Page 24: ITB2016 - Mixing up the front end with ColdBox elixir

Javascript • Concatenating Scripts

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

Page 25: ITB2016 - Mixing up the front end with ColdBox elixir

Javascript • ES6 Transpiling

elixir( function( mix ){ // ./resources/js/app.js mix.babel( "app.js" ); // ./includes/js/app.js} );

Page 26: ITB2016 - Mixing up the front end with ColdBox elixir

Javascript • Module Bundling

elixir( function( mix ){ mix.browserify( "app.js" );} );

Page 27: ITB2016 - Mixing up the front end with ColdBox elixir

Watch Mode

gulp watch

Page 28: ITB2016 - Mixing up the front end with ColdBox elixir

Asset Versioning

Page 29: ITB2016 - Mixing up the front end with ColdBox elixir

Asset Versioning

elixir( function( mix ){ mix.sass( "app.scss" ) .scripts( [ "jquery.js", "bootstrap.js" ] ) .version( [ "css/all.css", // => "includes/build/all-16d570a7.css" "js/all.js" // => "includes/build/all-89de4a22.js" ] );} );

Page 30: ITB2016 - Mixing up the front end with ColdBox elixir

Asset Versioning • ColdBox Helper Functions

<html> <head> #elixir( "css/all.css" )# </head> <body> ....

#elixir( "js/all.js" )# </body></html>

Page 31: ITB2016 - Mixing up the front end with ColdBox elixir

Minification in one line!gulp --production

Page 32: ITB2016 - Mixing up the front end with ColdBox elixir

Live Reloading

Page 33: ITB2016 - Mixing up the front end with ColdBox elixir

Live Reloading

elixir( function( mix ){ mix.browserSync(); // OR specify your proxy server mix.browserSync( { proxy: "127.0.0.1:7777" } );} );

Page 34: ITB2016 - Mixing up the front end with ColdBox elixir

Live Reloading

Page 35: ITB2016 - Mixing up the front end with ColdBox elixir

Live ReloadingThis is awesome for TestBox tests!

Page 36: ITB2016 - Mixing up the front end with ColdBox elixir

Custom ExtensionsFigure it out in Gulp, once

Page 37: ITB2016 - Mixing up the front end with ColdBox elixir

Custom Extensions

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

var Task = elixir.Task;

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

new Task( "speak", function(){ return gulp.src( "" ).pipe( shell( "say " + message ) ); });

});

mix.speak( "Hello World" );

Page 38: ITB2016 - Mixing up the front end with ColdBox elixir

Get Started!box coldbox create app skeleton=coldbox-templates/elixirnpm installgulp

Page 39: ITB2016 - Mixing up the front end with ColdBox elixir

Demo

Page 40: ITB2016 - Mixing up the front end with ColdBox elixir

Check out the docshttp://coldbox-elixir.ortusbooks.com/

Page 41: ITB2016 - Mixing up the front end with ColdBox elixir

Other Sessions at dev.Objective()

CFML Sessions for DummiesWednesday3:00 PM to 4:00 PM

Live Testing a Legacy AppThursday1:45 PM to 2:45 PM

Page 42: ITB2016 - Mixing up the front end with ColdBox elixir

Thank You!! elpete

@_elpete

! dev.elpete.com