ben-rogerson / laravel-mix-twig-to-html

A Laravel Mix extension to convert Twig files to Html
MIT License
9 stars 6 forks source link

Asset injection #2

Closed temosis closed 5 years ago

temosis commented 5 years ago

Add Option to disabled injection for HtmlWebpackPlugin

ben-rogerson commented 5 years ago

Sounds like a great feature, I'll let you know when it's added.

ben-rogerson commented 5 years ago

Hey @temosis, I've just released v1.2.0 which adds this option.

Here's how you can now disable injection:

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

require('laravel-mix-twig-to-html');

const files = [
    {
        template: 'src/templates/about/**/*.twig',
        title: 'About',
        inject: false, // disable asset tag injection
    },
    {
        template: 'src/templates/index.twig',
        title: 'Home',
        inject: false, // disable asset tag injection
    }
]

mix.twigToHtml({
    files: files,
    fileBase: 'src/templates',
});
ryanscherler commented 5 years ago

Looks like this option is enabled by default for the new globs option. Can we disable by default and enable on a per file config as noted above? Maybe a fileOptions for global globs?

{
    files: 'src/templates/**/*.{twig,html}',
    fileOptions: {
      inject: false,
    },
    fileBase: 'src/templates',
    twigOptions: { data: {} },
  }