Skip to content

justkidding96/include-replace-webpack-plugin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 

Repository files navigation

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'
        })
    ],
});

About

Custom include and replace plugin for webpack

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published