Skip to content
This repository was archived by the owner on Feb 1, 2020. It is now read-only.

Commit 46969ee

Browse files
committed
Check webpack version by checking of hooks api exists
1 parent 5e57216 commit 46969ee

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/index.js

+5-2
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,8 @@ import Purgecss from 'purgecss'
33
import { ConcatSource } from 'webpack-sources'
44
import * as parse from './parse'
55
import * as search from './search'
6-
import webpack from 'webpack'
76

8-
const webpackVersion = parseInt(webpack.version || 3)
7+
let webpackVersion = 4
98

109
const styleExtensions = ['.css', '.scss', '.styl', '.sass', '.less']
1110
const pluginName = 'PurgeCSS'
@@ -16,6 +15,10 @@ export default class PurgecssPlugin {
1615
}
1716

1817
apply(compiler) {
18+
if (typeof compiler.hooks === 'undefined') {
19+
webpackVersion = 3
20+
}
21+
1922
if (webpackVersion === 4) {
2023
compiler.hooks.compilation.tap(pluginName, compilation => {
2124
this.initializePlugin(compilation)

0 commit comments

Comments
 (0)