interpolate-loader
Webpack loader to interpolate require results.
Useful if you need to use a manifest file as an entry point to your application.
Pairs well with prop-loader
and entry-loader
/ spawn-loader
(see below).
Usually, you will want to pipe the output from this loader into extricate-loader
(to resolve the imports) and then file-loader
(to emit a non-js manifest file).
Installation
npm install --save-dev interpolate-loader
Options
Prefix/suffix
If you supply a query, it must contain both prefix
and suffix
.
Examples
interpolate-loader?prefix=(*&suffix=*)
interpolate-loader?prefix=%3C%25&suffix=%25%3E
(lodash-style <%
and %>
)
Defaults
prefix
: {{
suffix
: }}
Example Usage
webpack.config.js:
var InertEntryPlugin = ; // maybe unnecessary, see below moduleexports = entry: 'extricate-loader!interpolate-loader!manifest.json' output: filename: 'manifest.json' module: rules: test: /\.html$/ use: loader: 'file-loader' options: name: '[name].[ext]' 'extricate-loader' 'html-loader' plugins: // This is required to use manifest.json as the entry point. // If the entry point is a .js file and this loader is only used // for subresources, then it is not necessary. ;
manifest.json:
Output
manifest.json: