title: Module not found: Error: Can't resolve 'fs' Using Webpack
body: <p>Hi im using socket io in my application. Which is requiring fs. when i try to bundle my javascript using below webpack config. im getting error can not resolve 'fs'.</p>
  
  <pre><code>Module not found: Error: Can't resolve 'fs' in 'my application path/node_modules/socket.io/lib'
  </code></pre>
  
  <p>i found by adding <code>target:'node'</code> and <code>node:{fs:'empty'}</code>. this issue got resolved. </p>
  
  <p>But there is an issue in sass-loader. Getting below error.</p>
  
  <pre><code>ERROR in javascript/bundle.js from UglifyJs
  Unexpected token: name (zlibLimiter) [javascript/bundle.js:60019,4]
  Child extract-text-webpack-plugin ../../../node_modules/extract-text-webpack-plugin/dist ../../../node_modules/css-loader/index.js??ref--2-2!../../../node_modules/sass-loader/lib/loader.js!s
  </code></pre>
  
  <p>running the application ignoring above error. getting below error.</p>
  
  <pre><code>external "crypto":1 Uncaught ReferenceError: require is not defined
      at Object.__decorate (external "crypto":1)
      at __webpack_require__ (bootstrap 93620a17882f7a2aa1d3:19)
      at Object.byteToHex (rng.js:4)
      at __webpack_require__ (bootstrap 93620a17882f7a2aa1d3:19)
  </code></pre>
  
  <p>Below is my webpack config and versions. Can some one please help me to resolve this issue.</p>
  
  <p>"webpack": "~3.6.0",
  npm -v 5.8.0
  node -v v8.4.0</p>
  
  <pre><code>const webpack = require('webpack');
  const env = process.env.NODE_ENV;
  const ExtractTextPlugin = require('extract-text-webpack-plugin');
  const path = require('path');
  const extractSass = new ExtractTextPlugin({
    filename: 'css/[name].css',
    allChunks: false
  });
  
  
  let output = {
    path: __dirname + '/src/main/resources/static/',
    filename: 'javascript/[name].js'
  };
  
  if (env === 'debug' || env === 'nondev') {
    output = {
      path: __dirname + '/target/classes/static/',
      filename: 'javascript/[name].js'
    };
  }
  
  let config = {
    context: __dirname + '/app/js/src',
    entry: {
      bundle: './index.jsx',
      application: './static/scss/application.scss',
      'application-pdap': './static/scss/application-pdap.scss'
    },
    output: output,
    devtool: 'cheap-module-source-map',
    module: {
      rules: [
        {
          test: /.jsx?$/,
          loader: 'babel-loader',
          exclude: /node_modules/,
          query: {presets: ['es2015', 'react']}
        },
        {
          test: /\.(woff|woff2|eot|ttf|svg|png|jpg|gif)$/,
          loader: 'file-loader?limit=1024&amp;name=images/[name].[ext]'
        },
        {
          test: /\.(scss|css)$/,
          include: [path.resolve(__dirname, 'app/js/src/static/scss')],
          use: ExtractTextPlugin.extract({
            publicPath: '../',
            use: [
              {
                loader: 'css-loader',
                options: {
                  minimize: true,
                  sourceMap: false
                }
              },
              {loader: 'sass-loader'}
            ],
            fallback: 'style-loader'
          })
        }
      ]
    },
    plugins: [extractSass],
  
  };
  
  if (env === 'production' || env === 'nondev') {
    config.devtool = 'nosources-source-map';
  
    config.plugins.push(
      new webpack.DefinePlugin({
        'process.env': {NODE_ENV: '"production"'}
      })
    );
  
    config.plugins.push(new webpack.optimize.UglifyJsPlugin({
      compress: {warnings: false},
      comments: false,
      sourceMap: false,
      minimize: false
    }));
  }
  
  module.exports = config;
  </code></pre>