ReactJs + webpack + ie + console.log

I have a project wrote in JSX and I use webpack to build the main.js file.

This is my webpack.config.js:

var path = require('path');

module.exports = {
  entry:{  main: [

  output: {
    filename: '[name].js',
    chunkFilename: '[id].chunk.js',
    path: path.join('public', 'js'),
    publicPath: '/js/'

  module: {
    loaders: [
      { test: /\.js$/, loader: 'jsx-loader?harmony&insertPragma=React.DOM' },
      { test: require.resolve('react'), loader: 'expose?React' },


My problem is that I cannot make my project work under IE (I test with IE9 at the moment). It always says "console is undefined".

With Firefox and Chrome it works perfectly.

What do I do wrong?

I tried with console-polyfill too but same result.

IE9 says that it fails at this line of javascript code :

_deprecationWarning2['default']('CollapsableNav', 'CollapsibleNav', '');

But there is no console.log on it.

What do I do wrong?

Thank you in advance!


In browsers that don't support console, you need to strip console functions from your code. For webpack you can use webpack-strip. One way to use is as follows:

var WebpackStrip = require('webpack-strip')

Then add { test: /\.js$/, loader: WebpackStrip.loader('console.log', 'console.error') } to loaders to strip console.log and console.error

    module: {
        loaders: [
            { test: /\.js$/, loader: 'jsx-loader?harmony&insertPragma=React.DOM' },
            { test: require.resolve('react'), loader: 'expose?React' },
            { test: /\.js$/, loader: WebpackStrip.loader('console.log', 'console.error') }

You have to put both loaders in the same line. Instead of using loader, use loaders and pass an array with both loaders.

Need Your Help

Cross Compiling Perl or Expect for MIPS Processor

perl cross-platform mips expect codesourcery

I am working with an embedded board that has a MIPS processsor. I am supposed to be developing tests for the system with different applications. My question is: is there a way to cross-compile Per...

Writing 'bits' to C++ file streams

java c# python c++ bit-manipulation

How can I write 'one bit' into a file stream or file structure each time?