GithubHelp home page GithubHelp logo

laravel-mix-handlebars's Introduction

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'] }
            })
        ]
    };
});

laravel-mix-handlebars's People

Contributors

4ern avatar bizsimon avatar iwt-etschernjaew avatar tasinttttttt avatar

Stargazers

 avatar  avatar

Watchers

 avatar

laravel-mix-handlebars's Issues

Missing changes in the npm package

Hi,

I installed this package (v1.0.3) from npm but couldn't make it work (on linux).
The changes made in this PR #3 are not present in the npm version.

Thank you

Cannot find module 'Handlebars'

This is running on Linux, not sure if that has anything to do with it.

(node:575434) UnhandledPromiseRejectionWarning: Error: Cannot find module 'Handlebars'
Require stack:
- /project/node_modules/laravel-mix-handlebars/render.js
- /project/node_modules/laravel-mix-handlebars/index.js
- /project/webpack.mix.js
- /project/node_modules/laravel-mix/setup/webpack.config.js
- /project/node_modules/webpack-cli/lib/webpack-cli.js
- /project/node_modules/webpack-cli/lib/bootstrap.js
- /project/node_modules/webpack-cli/bin/cli.js
- /project/node_modules/webpack/bin/webpack.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:831:15)
    at Function.Module._load (internal/modules/cjs/loader.js:687:27)
    at Module.require (internal/modules/cjs/loader.js:903:19)
    at require (/project/node_modules/v8-compile-cache/v8-compile-cache.js:159:20)
    at HandlebarTask.precompile (/project/node_modules/laravel-mix-handlebars/render.js:29:27)
    at HandlebarTask.run (/project/node_modules/laravel-mix-handlebars/render.js:12:14)
    at CustomTasksPlugin.runTask (/project/node_modules/laravel-mix/src/webpackPlugins/CustomTasksPlugin.js:38:36)
    at CustomTasksPlugin.runTasks (/project/node_modules/laravel-mix/src/webpackPlugins/CustomTasksPlugin.js:79:21)
    at /project/node_modules/laravel-mix/src/webpackPlugins/CustomTasksPlugin.js:12:18
    at Hook.eval [as callAsync] (eval at create (/project/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:70:1)
(node:575434) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.