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

Commit ce78a17

Browse files
tsukachuchrisbreiding
authored andcommitted
patch: Use new .hooks api, remove deprecation warning (Fixes #32)
Fix #32
1 parent af12b41 commit ce78a17

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

index.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,9 @@ const preprocessor = (options = {}) => {
129129
}
130130

131131
// this event is triggered when watching and a file is saved
132-
compiler.plugin('compile', () => {
132+
const plugin = { name: 'CypressWebpackPreprocessor' }
133+
134+
const onCompile = () => {
133135
log('compile', filePath)
134136
// we overwrite the latest bundle, so that a new call to this function
135137
// returns a promise that resolves when the bundling is finished
@@ -140,7 +142,13 @@ const preprocessor = (options = {}) => {
140142
// to let Cypress know to re-run the spec
141143
file.emit('rerun')
142144
})
143-
})
145+
}
146+
147+
if (compiler.hooks) {
148+
compiler.hooks.compile.tap(plugin, onCompile)
149+
} else {
150+
compiler.plugin('compile', onCompile)
151+
}
144152

145153
if (file.shouldWatch) {
146154
log('watching')

0 commit comments

Comments
 (0)