Wrap entry points with any code
This plugin is useful when you need to wrap entry point with custom code, which should be executed before original entry point. Plugin provides path to an original entry point so you need to import it manually in your wrapper.
E.g. you need to set public path in runtime but don't want to have this logic in entry point.
npm i -D webpack-entry-wrapper
const WebpackEntryWrapper = require('webpack-entry-wrapper');
module.exports = {
entry: './main',
plugins: [
new WebpackEntryWrapper({
include: /main.js/,
template: 'data/template.js'
})
]
}
template example
const entry = require('${entry}');
console.log(entry);
Name | Type | Default | Description |
---|---|---|---|
include |
{RegExp} |
null | included entries, By default plugin applies to all entry points |
template (required) |
string |
undefined | Path to a wrapper template |
Variable | Description |
---|---|
entry |
relative path to entry point |