Single Page Application With Independent UI.
A true single page application is one which solely treats it's api as a resource provider and does not have any dependency on its backend, Not even for hosting. Thus a single page application can be deployed separately on a different server, CDN or can be packed and shipped as electron app.
Laravel provides a very good tool called as elixir for compiling assets and defining gulp task. It does attaches cache buster at the end of all generated assets through versioning. As of now this version string is available with Laravel view variables. This adds a point of tight coupling with Laravel and UI.
Laravel Elixir Index Builder Package breaks this dependency by giving a build folder with index.html file it.
This package helps you to build index.html as a laravel-elixir task which should be called post version call.
Index builder uses simple pug template to craft your index.html. Along with cache busted versioned files are injected during pug transpilation.
Additional configs can be passed to index builder as a part of configs.
Installation
npm install laravel-elixir-index-builder
Usage
Include laravel-elixir-index-builder
var indexBuilder = require('laravel-elixir-index-builder');
for ECMA2015
import indexBuilder from 'laravel-elixir-index-builder';
Initialize it with existing elixir.
indexBuilder(elixir);
call buildIndex task post version call.
mix.sass(['*.scss'], 'public/css/app.css')
.browserify('test.js', './public/build/app.js')
.scripts([ './public/build/app.js'], './public/js/all.js')
.version(["css/app.css", "js/all.js"])
.buildIndex();
Please or to participate in this conversation.