include-replace-webpack-plugin

2.0.0 • Public • Published

Include and replace

Use @@include('partial.html') inside your HTML files and include the partial and replace the content of it. Or give custom data to the partial and show it with @@show('title').

Example:
@@include('partial.html', {"title": "My custom title"}) // in index.html
@@show('title') // in partial.html

Installation

Inside webpack:

let IncludeReplaceWebpackPlugin = require('include-replace');

// Require this inside your plugins array
new IncludeReplaceWebpackPlugin({
    src: './src',
    dist: './dist'
});

For Laravel mix:

let IncludeReplaceWebpackPlugin = require('include-replace');

// Extend the default Webpack config
mix.webpackConfig({
    plugins: [
        new IncludeReplaceWebpackPlugin({
            src: './src',
            dist: './dist'
        })
    ],
});

For Laravel mix + browsersync

let IncludeReplaceWebpackPlugin = require('include-replace');
let plugin;

// Extend the default Webpack config
mix.browserSync({
    proxy: 'domain.local',
    files: [
        'src/**/*',
        {
            match: 'src/**/*',
            fn: function(event, file) {
                plugin.compileHook();
            }
        },
        'dist/**/*',
    ]
})
.webpackConfig({
    plugins: [
        plugin = new IncludeReplaceWebpackPlugin({
            src: './src',
            dist: './dist'
        })
    ],
});

Readme

Keywords

Package Sidebar

Install

npm i include-replace-webpack-plugin

Weekly Downloads

1

Version

2.0.0

License

MIT

Unpacked Size

5.86 kB

Total Files

3

Last publish

Collaborators

  • justkidding96