Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

html-webpack-plugin

Package Overview
Dependencies
Maintainers
2
Versions
141
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

html-webpack-plugin - npm Package Compare versions

Comparing version 2.7.2 to 2.8.0

lib/chunksorter.js

24

index.js

@@ -9,2 +9,3 @@ 'use strict';

var prettyError = require('./lib/errors.js');
var chunkSorter = require('./lib/chunksorter.js');
Promise.promisifyAll(fs);

@@ -283,15 +284,5 @@

// Sort mode auto by default:
if (typeof sortMode === 'undefined' || sortMode === 'auto') {
return chunks.sort(function orderEntryLast (a, b) {
if (a.entry !== b.entry) {
return b.entry ? 1 : -1;
} else {
return b.id - a.id;
}
});
if (typeof sortMode === 'undefined') {
sortMode = 'auto';
}
// Disabled sorting:
if (sortMode === 'none') {
return chunks;
}
// Custom function

@@ -301,3 +292,10 @@ if (typeof sortMode === 'function') {

}
// Invalid sort mode
// Disabled sorting:
if (sortMode === 'none') {
return chunkSorter.none(chunks);
}
// Check if the given sort mode is a valid chunkSorter sort mode
if (typeof chunkSorter[sortMode] !== 'undefined') {
return chunkSorter[sortMode](chunks);
}
throw new Error('"' + sortMode + '" is not a valid chunk sort mode');

@@ -304,0 +302,0 @@ };

{
"name": "html-webpack-plugin",
"version": "2.7.2",
"version": "2.8.0",
"description": "Simplifies creation of HTML files to serve your webpack bundles",

@@ -39,2 +39,3 @@ "main": "index.js",

"html-loader": "^0.4.0",
"jade": "^1.11.0",
"jade-loader": "^0.8.0",

@@ -54,4 +55,5 @@ "jasmine-node": "^1.14.5",

"lodash": "^3.10.1",
"pretty-error": "^2.0.0"
"pretty-error": "^2.0.0",
"toposort": "^0.2.12"
}
}

@@ -19,2 +19,9 @@ HTML Webpack Plugin

Migration guide from 1.x
------------------------
If you used the 1.x version please take a look at the [migration guide](https://github.com/ampedandwired/html-webpack-plugin/blob/master/migration.md)
In case I missed something please open a pull request for it.
See also issue [#186](https://github.com/ampedandwired/html-webpack-plugin/issues/186)
Basic Usage

@@ -77,3 +84,3 @@ -----------

- `chunks`: Allows you to add only some chunks (e.g. only the unit-test chunk)
- `chunksSortMode`: Allows to controll how chunks should be sorted before they are included to the html. Allowed values: 'none' | 'default' | {function} - default: 'auto'
- `chunksSortMode`: Allows to control how chunks should be sorted before they are included to the html. Allowed values: 'none' | 'auto' | 'dependency' | {function} - default: 'auto'
- `excludeChunks`: Allows you to skip some chunks (e.g. don't add the unit-test chunk)

@@ -131,3 +138,3 @@

title: 'Custom template',
template: 'my-index.html', // Load a custom template
template: 'my-index.ejs', // Load a custom template
inject: 'body' // Inject all scripts into the body

@@ -138,3 +145,3 @@ })

`my-index.html`:
`my-index.ejs`:

@@ -154,2 +161,3 @@ ```html

If you already have a template loader, you can use it to parse the template.
Please note that this will also happen if you specifiy the html-loader and use `.html` file as template.

@@ -165,4 +173,3 @@ ```javascript

title: 'Custom template using Handlebars',
template: 'my-index.hbs',
inject: 'body'
template: 'my-index.hbs'
})

@@ -172,45 +179,6 @@ ]

Alternatively, if you already have your template's content in a String, you
can pass it to the plugin using the `templateContent` option:
```javascript
plugins: [
new HtmlWebpackPlugin({
inject: true,
templateContent: templateContentString
})
]
```
You can use the lodash syntax out of the box.
If the `inject` feature doesn't fit your needs and you want full control over the asset placement use the [default template](https://github.com/ampedandwired/html-webpack-plugin/blob/master/default_index.ejs)
as a starting point for writing your own.
If the `inject` feature doesn't fit your needs and you want full control over the asset placement use the [default template](https://github.com/jaketrent/html-webpack-template/blob/86f285d5c790a6c15263f5cc50fd666d51f974fd/index.html) of the [html-webpack-template project](https://github.com/jaketrent/html-webpack-template) as a starting point for writing your own.
The `templateContent` option can also be a function to use another template language like jade:
```javascript
plugins: [
new HtmlWebpackPlugin({
templateContent: function(templateParams, compilation) {
// Return your template content synchronously here
return '..';
}
})
]
```
Or the async version:
```javascript
plugins: [
new HtmlWebpackPlugin({
templateContent: function(templateParams, compilation, callback) {
// Return your template content asynchronously here
callback(null, '..');
}
})
]
```
Note the plugin will throw an error if you specify both `template` _and_
`templateContent`.
The `o` variable in the template is the data that is passed in when the
template is rendered. This variable has the following attributes:
The following variables are available in the:
- `htmlWebpackPlugin`: data specific to this plugin

@@ -217,0 +185,0 @@ - `htmlWebpackPlugin.files`: a massaged representation of the

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc