Handlebars

Laravel Mix support for Handlebars.js and Handlebars Layouts.
latest v1.0.3 - released
4ern
97 downloads last week
MIT license
4 versions
Laravel-Mix
Handlebars
Handlebars Layout
Webpack

laravel-mix-handlebars plugin for Laravel-Mix

With this plugin you can use Handlebars and Handlebars-Layout with Laravel-Mix.

Install:

$ npm install --save-dev laravel-mix-handlebars

or

$ yarn add --dev laravel-mix-handlebars

Usage:

in your webpack.mix.js:

const mix = require('laravel-mix');
require('laravel-mix-handlebars');

/// mix.handlebars('your source folder', 'your dist or public folder', {your vars})
mix.handlebars('src/', 'dist/');

Note:

  • The file extension must be .hbs.
  • Partials must begin with an underscore so that they are recognized as partials. _myPartial.hbs.

Workaround for BrowserSync:

// webpack.mix.js
const mix = require('laravel-mix');
const BrowserSyncPlugin = require('browser-sync-webpack-plugin');

mix.webpackConfig(() => {
    return {
        plugins: [
            new BrowserSyncPlugin({
                host: 'localhost',
                port: 3003,
                watch: true,
                server: { baseDir: ['dist'] }
            })
        ]
    };
});