All Projects → jamesjieye → html-webpack-exclude-assets-plugin

jamesjieye / html-webpack-exclude-assets-plugin

Licence: MIT license
Add the ability to exclude assets based on RegExp patterns

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to html-webpack-exclude-assets-plugin

link-media-html-webpack-plugin
parses CSS filenames to automatically apply media HTML attribute to link elements
Stars: ✭ 15 (-70%)
Mutual labels:  html-webpack-plugin
Prerender Loader
📰 Painless universal pre-rendering for Webpack.
Stars: ✭ 1,908 (+3716%)
Mutual labels:  html-webpack-plugin
Html Webpack Plugin
Simplifies creation of HTML files to serve your webpack bundles
Stars: ✭ 9,942 (+19784%)
Mutual labels:  html-webpack-plugin
webpack-4-react-bootstrap-starter-template
Starter boilerplate template for webpack 4 with React, Bootstrap 4
Stars: ✭ 16 (-68%)
Mutual labels:  html-webpack-plugin
nunjucks-loader
Webpack loader for Nunjucks templates
Stars: ✭ 20 (-60%)
Mutual labels:  html-webpack-plugin
interpolate-html-plugin
Webpack plugin for interpolating custom variables into index.html
Stars: ✭ 60 (+20%)
Mutual labels:  html-webpack-plugin
html-webpack-partials-plugin
🛠 Easy HTML partials for Webpack without a custom index!
Stars: ✭ 68 (+36%)
Mutual labels:  html-webpack-plugin
css-chunks-html-webpack-plugin
Injecting css chunks extracted using extract-css-chunks-webpack-plugin to HTML for html-webpack-plugin
Stars: ✭ 22 (-56%)
Mutual labels:  html-webpack-plugin

Exclude Assets extension for the HTML Webpack Plugin

npm version Build Status js-semistandard-style

Enhances html-webpack-plugin functionality by adding the {excludeAssets: RegExp | [RegExp]} option to allow you to exclude assets.

When adding an entry with third party css files, for example, style: ['bootstrap/dist/css/bootstrap.css'], to webpack, the injected scripts include style.js or style.[chunkhash].js. The excludeChunks option of html-webpack-plugin will exclude both style.css and style.js. With this plugin, you can keep style.css in and style.js out by setting excludeAssets: /style.*.js/.

You can also exclude CSS assets, for example, a theme CSS style, by setting excludeAssets: /theme.*.css/.

Installation

You must be running webpack on Node v4.0.0 or higher.

Note: style-loader's dependency loader-utils only supports Node v4.0.0 since v1.0. See style-loader's #174 pull request for details.

Install the plugin with npm:

$ npm install --save-dev html-webpack-exclude-assets-plugin

Basic Usage

Require the plugin in your webpack config:

var HtmlWebpackExcludeAssetsPlugin = require('html-webpack-exclude-assets-plugin');

Add the plugin to your webpack config as follows:

plugins: [
  new HtmlWebpackPlugin(),
  new HtmlWebpackExcludeAssetsPlugin()
]  

The above configuration will actually do nothing due to the configuration defaults.

When you set excludeAssets to an array of regular expressions or a single regular expression, the matched assets will be skipped when the chunks are injected into the HTML template.

plugins: [
  new HtmlWebpackPlugin({
    excludeAssets: [/style.*.js/] // exclude style.js or style.[chunkhash].js 
  }),
  new HtmlWebpackExcludeAssetsPlugin()
]  
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].