JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 149
  • Score
    100M100P100Q78084F
  • License MIT

Laravel Mix extension to compile EJS templates

Package Exports

  • laravel-mix-ejs

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (laravel-mix-ejs) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Laravel Mix EJS

This extention provides a method to compile EJS templates.

Usage

First, install the extension.

npm install laravel-mix-ejs --save-dev

Then, require it within your webpack.mix.js file, like so:

let mix = require('laravel-mix');

require('laravel-mix-ejs');

mix
    .js('resources/js/app.js', 'public/js')
    .sass('resources/sass/app.scss', 'public/css')
    .ejs(
      [ `resources/views/**/*`, `!resources/views/partials` ],
      'public'
    );

And you're done!

Data

With the 3rd argument, it is possible to inject variables used in templates.

mix.ejs(
    [ `resources/views/**/*`, `!resources/views/partials` ],
    'public',
    { foo: 'bar' }
)

Options

With the 4th argument, it is possible to set options for EJS.

mix.ejs(
    [ `resources/views/**/*`, `!resources/views/partials` ],
    'public',
    { foo: 'bar' },
    { rmWhitespace: true }
)

You can also set the following two extra options in it.

base

This option keeps a hierarchical structure (like Gulp).

mix.ejs(
    [ `resources/views/**/*`, `!resources/views/partials` ],
    'public',
    { foo: 'bar' },
    { base: 'resources/views' }
)

ext

This option changes the output file extension.

mix.ejs(
    [ `resources/views/**/*`, `!resources/views/partials` ],
    'public',
    { foo: 'bar' },
    { ext: '.php' }
)