Skip to content

Commit ae1f435

Browse files
committed
feat: Switch from jasmine to jest
1 parent 82b34a1 commit ae1f435

File tree

22 files changed

+241
-207
lines changed

22 files changed

+241
-207
lines changed

README.md

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -287,15 +287,19 @@ plugins: [
287287

288288
### `Events`
289289

290-
To allow other [plugins](https://github.com/webpack/docs/wiki/plugins) to alter the HTML this plugin executes the following events:
290+
To allow other [plugins](https://github.com/webpack/docs/wiki/plugins) to alter the HTML this plugin executes
291+
[tapable](https://github.com/webpack/tapable/tree/master) hooks.
291292

292-
#### `AsyncSeriesWaterfallHook`
293+
The [lib/hooks.js](https://github.com/jantimon/html-webpack-plugin/blob/master/lib/hooks.js) contains all information
294+
about which values are passed.
293295

294-
* `htmlWebpackPluginBeforeHtmlGeneration`
295-
* `htmlWebpackPluginBeforeHtmlProcessing`
296-
* `htmlWebpackPluginAlterAssetTags`
297-
* `htmlWebpackPluginAfterHtmlProcessing`
298-
* `htmlWebpackPluginAfterEmit`
296+
You can tap into the following async hooks:
297+
298+
* `beforeHtmlGeneration`
299+
* `beforeHtmlProcessing`
300+
* `alterAssetTags`
301+
* `afterHtmlProcessing`
302+
* `afterEmit`
299303

300304
Example implementation: [html-webpack-harddisk-plugin](https://github.com/jantimon/html-webpack-harddisk-plugin)
301305

@@ -308,8 +312,10 @@ function MyPlugin(options) {
308312
MyPlugin.prototype.apply = function (compiler) {
309313
compiler.hooks.compilation.tap('MyPlugin', (compilation) => {
310314
console.log('The compiler is starting a new compilation...');
311-
HtmlWebpackPlugin.getHooks(compilation).htmlWebpackPluginAfterHtmlProcessing.tapAsync(
312-
'MyPlugin',
315+
316+
// | HOOK NAME |
317+
HtmlWebpackPlugin.getHooks(compilation).afterHtmlProcessing.tapAsync(
318+
'MyPlugin', // <-- Set a meaningful name here for stacktraces
313319
(data, cb) => {
314320
data.html += 'The Magic Footer'
315321

examples/appcache/dist/webpack-4/manifest.appcache

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
CACHE MANIFEST
2-
# 95a89258cd32fe3f01e3
2+
# a351a7eb0665a7fa27b3
33

44
0714810ae3fb211173e2964249507195.png
55
bundle.js

examples/appcache/webpack.config.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ module.exports = {
1313
filename: 'bundle.js'
1414
},
1515
module: {
16-
loaders: [
17-
{ test: /\.css$/, loader: ExtractTextPlugin.extract('style-loader', 'css-loader') },
16+
rules: [
17+
{ test: /\.css$/, loader: ExtractTextPlugin.extract({ fallback: 'style-loader', use: 'css-loader' }) },
1818
{ test: /\.png$/, loader: 'file-loader' },
1919
{ test: /\.html$/, loader: 'html-loader?-removeOptionalTags' }
2020
]

examples/build-examples.js

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,6 @@ var fs = require('fs');
1010
var path = require('path');
1111
var rimraf = require('rimraf');
1212
var webpack = require('webpack');
13-
var ExtractTextPlugin = require('extract-text-webpack-plugin');
14-
15-
if (Number(webpackMajorVersion) > 1) {
16-
var extractOriginal = ExtractTextPlugin.extract;
17-
ExtractTextPlugin.extract = function (fallback, use) {
18-
return extractOriginal({
19-
fallback: fallback,
20-
use: use
21-
});
22-
};
23-
}
2413

2514
var examples = fs.readdirSync(__dirname).filter(function (file) {
2615
return fs.statSync(path.join(__dirname, file)).isDirectory();
@@ -39,10 +28,6 @@ examples.forEach(function (exampleName) {
3928
}));
4029
config.mode = 'production';
4130
config.optimization = { minimizer: [] };
42-
if (config.module && config.module.loaders) {
43-
config.module.rules = config.module.loaders;
44-
delete config.module.loaders;
45-
}
4631
}
4732

4833
rimraf.sync(path.join(examplePath, 'dist', 'webpack-' + webpackMajorVersion));

examples/custom-template/webpack.config.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ module.exports = {
1212
filename: 'bundle.js'
1313
},
1414
module: {
15-
loaders: [
16-
{ test: /\.css$/, loader: ExtractTextPlugin.extract('style-loader', 'css-loader') },
15+
rules: [
16+
{ test: /\.css$/, loader: ExtractTextPlugin.extract({ fallback: 'style-loader', use: 'css-loader' }) },
1717
{ test: /\.png$/, loader: 'file-loader' }
1818
]
1919
},

examples/default/webpack.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ module.exports = {
1010
filename: 'bundle.js'
1111
},
1212
module: {
13-
loaders: [
13+
rules: [
1414
{ test: /\.css$/, loader: 'style-loader!css-loader' },
1515
{ test: /\.png$/, loader: 'file-loader' }
1616
]

examples/favicon/webpack.config.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ module.exports = {
1111
filename: 'bundle.js'
1212
},
1313
module: {
14-
loaders: [
15-
{ test: /\.css$/, loader: ExtractTextPlugin.extract('style-loader', 'css-loader') },
14+
rules: [
15+
{ test: /\.css$/, loader: ExtractTextPlugin.extract({ fallback: 'style-loader', use: 'css-loader' }) },
1616
{ test: /\.png$/, loader: 'file-loader' }
1717
]
1818
},

examples/html-loader/webpack.config.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ module.exports = {
1111
filename: 'bundle.js'
1212
},
1313
module: {
14-
loaders: [
15-
{ test: /\.css$/, loader: ExtractTextPlugin.extract('style-loader', 'css-loader') },
14+
rules: [
15+
{ test: /\.css$/, loader: ExtractTextPlugin.extract({ fallback: 'style-loader', use: 'css-loader' }) },
1616
{ test: /\.png$/, loader: 'file-loader' },
1717
{ test: /\.html$/, loader: 'html-loader' }
1818
]

examples/inline/webpack.config.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ module.exports = {
1212
filename: 'bundle.js'
1313
},
1414
module: {
15-
loaders: [
16-
{ test: /\.css$/, loader: ExtractTextPlugin.extract('style-loader', 'css-loader') },
15+
rules: [
16+
{ test: /\.css$/, loader: ExtractTextPlugin.extract({ fallback: 'style-loader', use: 'css-loader' }) },
1717
{ test: /\.jade$/, loader: 'jade-loader' }
1818
]
1919
},
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<!DOCTYPE html><html><head><title>Jade demo</title><link rel="shortcut icon" href="favicon.ico"><link href="styles.css" rel="stylesheet"></head><body><div id="main"><!-- this partial is used for frontend and backend--><div class="time"> <b>Current time</b><p>1999-01-01T05:00:00.000Z</p></div><img src="0714810ae3fb211173e2964249507195.png"></div><script src="bundle.js"></script></body></html>
1+
<!DOCTYPE html><html><head><title>Jade demo</title><link rel="shortcut icon" href="favicon.ico"><link href="styles.css" rel="stylesheet"></head><body><div id="main"><!-- this partial is used for frontend and backend--><div class="time"> <b>Current time</b><p>1998-12-31T23:00:00.000Z</p></div><img src="0714810ae3fb211173e2964249507195.png"></div><script src="bundle.js"></script></body></html>

0 commit comments

Comments
 (0)