Skip to content

Commit 4e37a14

Browse files
committed
Chore
1 parent 22de680 commit 4e37a14

File tree

3 files changed

+35
-3769
lines changed

3 files changed

+35
-3769
lines changed

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
src="https://raw.githubusercontent.com/webpack/media/master/logo/icon-square-big.png">
77
</a>
88
<h1>mangle-css-class-webpack-plugin</h1>
9-
<p>Minifies and obfuscates the class names in JavaScript, CSS, and HTML. WORKS ONLY WITH WEBPACK 5!</p>
9+
<p>Minifies and obfuscates the class names in JavaScript, CSS, and HTML.</p>
1010
</div>
1111

1212
<h2 align="center">Install</h2>
@@ -19,6 +19,9 @@
1919
yarn add --dev mangle-css-class-webpack-plugin
2020
```
2121

22+
The latest version WORKS ONLY with Webpack 5. For Webpack v4 & v3 support, install version 4.x(mangle-css-class-webpack-plugin@4.0.12).
23+
24+
2225
<h2 align="center">Usage</h2>
2326

2427
The plugin will generate optimized class name in HTML, JavaScript, and CSS files.

lib/plugin.js

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -14,25 +14,12 @@ class Plugin {
1414
}
1515

1616
apply(compiler) {
17-
if (compiler.hooks) {
18-
compiler.hooks.compilation.tap(
19-
'MangleCssClassPluginHooks',
20-
(compilation) => {
21-
if (compilation.hooks.processAssets) {
22-
// setup hooks for webpack >= 5
23-
compilation.hooks.processAssets.tapAsync('MangleCssClassPluginOptimizeChunkAssetsHooks', runner(compiler, compilation, this.opts));
24-
} else {
25-
// setup hooks for webpack >= 4
26-
compilation.hooks.optimizeChunkAssets.tapAsync('MangleCssClassPluginOptimizeChunkAssetsHooks', runner(compiler, compilation, this.opts));
27-
}
28-
}
29-
);
30-
} else {
31-
// setup hooks for webpack <= 3
32-
compiler.plugin('compilation', (compilation) => {
33-
compilation.plugin('optimize-chunk-assets', runner(compiler, compilation, this.opts));
34-
});
35-
}
17+
compiler.hooks.compilation.tap(
18+
'MangleCssClassPluginHooks',
19+
(compilation) => {
20+
compilation.hooks.processAssets.tapAsync('MangleCssClassPluginOptimizeChunkAssetsHooks', runner(compiler, compilation, this.opts));
21+
}
22+
);
3623
}
3724
}
3825

0 commit comments

Comments
 (0)