@dsktschy/laravel-mix-pug

1.0.0 • Public • Published

laravel-mix-pug

Laravel Mix Plugin for compiling Pug/Jade templates.

NPM NPM NPM

Introduction

This package provides a plugin for Laravel Mix to compile pug templates. @dsktschy/laravel-mix-pug requires Laravel Mix to work. Please follow the instructions on how to use it on the package repository.

Usage

Install this package into your project:

npm install @dsktschy/laravel-mix-pug --save-dev

Head over to your webpack.mix.js and register it on the Laravel Mix API:

let mix = require('laravel-mix');
mix.pug = require('@dsktschy/laravel-mix-pug');

mix.js('src/app.js', 'dist')
   .sass('src/app.scss', 'dist')
   .pug('src/*.pug', 'dist')
   .setPublicPath('dist');

Options

You can also pass in a third optional parameter: options object. It accepts two options:

seeds

This is a path to a folder with seed files. Files can be of type json or yaml. They will be parsed and provided in your pug template locals under the seed file name and then contents.

mix.pug('src/*.pug', 'dist', {seeds:'src/seeds'});

And if you have a file demo.yml in there all the content will be available in your template under

a(href=seed.demo.anchor.link) seed.demo.anchor.name

locals

It's possible to pass in an object which will be added to locals in your pug templates:

mix.pug('src/*.pug', 'dist', {
    locals: {
        config: { baseUrl: 'http://my-template.dev/' }
    }
});

and in your pug file:

link(rel="stylesheet" media="screen" href=`{config.baseUrl}css/app.css`)
script(src=`{config.baseUrl}js/main.js`)

pug

You can pass in pug config options under pug key:

mix.pug('src/*.pug', 'dist', {
    pug: {
        pretty: true,
        debug: true
    }
});

ext && excludePath

It is possible to change to output file extension and exlude part of the path. i.e.: You want your destination file to be in resources/assets/views and the folder structure in there to continue from the resources/assets/pug/{..}:

mix.pug('resources/assets/pug/*.pug', 'resources/assets/views', {
    ext: '.blade.php',
    exludePath: 'resources/assets/pug'
});

License

Laravel Mix Pug is open-sourced software licensed under the MIT license.

Readme

Keywords

Package Sidebar

Install

npm i @dsktschy/laravel-mix-pug

Weekly Downloads

0

Version

1.0.0

License

MIT

Unpacked Size

27.9 kB

Total Files

7

Last publish

Collaborators

  • dsktschy