Check your script is running on webpack-dev-server
$ npm install --save is-webpack
You will get true value from this module while building is going on with webpack
const isWebpack = require('is-webpack');
console.log(isWebpack);
//=> true
MIT © Jimmy Moon