handlebars-faker-loader

1.0.4 • Public • Published

Handlebars faker loader

This is an special webpack loader for handlebars

How to use

yarn add --dev handlebars-faker-loader handlebars

{
    test: /(\.faker\.js|\.handlebars)$/,
    use: [
        {
            loader: 'file-loader',
            options: {
                name(file) {
                    let finalName = /[\d\w_]+(\.faker\.js|\.handlebars)$/i.exec(file)[0].replace('.handlebars','.html').replace('.faker.js','.html')
                    return finalName;
                }
            }
        },
        {
            loader:'handlebars-faker-loader',
            options: {
                fakersDir:path.resolve(__dirname, 'src/fakers/'),
                viewsDir:path.resolve(__dirname, 'src/views/'),
                doNothing: true //(Optinal) If you dont want the puglin to act for some reason,
            }
        }
    ]
}

Faker example

    module.exports =()=>{
        return {
            lorem:'mama mia '
        };
    }

You have to name the file with the extension .faker.js, and the handlebars with the extension .handlebars

Package Sidebar

Install

npm i handlebars-faker-loader

Weekly Downloads

2

Version

1.0.4

License

MIT

Unpacked Size

4.01 kB

Total Files

4

Last publish

Collaborators

  • shacco