A webpack loader that evaluates source code on the fly and returns it as a string, primarily used to extract HTML and CSS from the bundle. Version 5.1.0 is the latest stable release, with slow updates since 2020. It resolves URLs within HTML and CSS, serving as a lean alternative to extract-text-webpack-plugin and mini-css-extract-plugin. It works specifically with code generated by html-loader or css-loader, providing a fake context for evaluation.
npm install extract-loaderVerified import paths — ran on the pinned version, not inferred.
Demonstrates using extract-loader with file-loader and css-loader to extract CSS as a separate file for production.
Ensure Node is 6+ and install babel-loader as a dependency.
Switch to mini-css-extract-plugin (for CSS) or handle HTML extraction differently.
Ensure the loaded resource is processed by html-loader or css-loader before extraction.
Use use: ['file-loader', 'extract-loader', ...] in webpack config.
Upgrade Node to 6+ or use v3.1.0.
Reorder loaders: use ['file-loader', 'extract-loader', 'css-loader']
Install babel-loader: npm install --save-dev babel-loader
Ensure the loaded module is CSS or HTML processed by respective loaders.