Adding certain babel plugins only while running tests

To override imports with stubs in my unit tests I use babel-plugin-rewire. However, this also modifies my code when not running normally. Is there a way to specify that babel-plugin-rewireshould only be used when testing?