<commit_before>var path = require('path');
var webpack = require('webpack');
var ExtractTextPlugin = require('extract-text-webpack-plugin');

var isDev = (process.env.NODE_ENV === 'development');
// these values are required in the config.app.js file -- we can't use
// process.env with webpack, we have to create these magic constants
// individually.
var defineEnvPlugin = new webpack.DefinePlugin({
  __UPLOAD_API__: JSON.stringify(process.env.UPLOAD_API || null),
  __API_HOST__: JSON.stringify(process.env.API_HOST || null),
  __INVITE_KEY__: JSON.stringify(process.env.INVITE_KEY || null),
  __PASSWORD_MIN_LENGTH__: JSON.stringify(process.env.PASSWORD_MIN_LENGTH || null),
  __PASSWORD_MAX_LENGTH__: JSON.stringify(process.env.PASSWORD_MAX_LENGTH || null),
  __ABOUT_MAX_LENGTH__: JSON.stringify(process.env.ABOUT_MAX_LENGTH || null),
  __DEV__: isDev,
  __TEST__: false,
  __DEV_TOOLS__: (process.env.DEV_TOOLS != null) ? process.env.DEV_TOOLS : (isDev ? true : false)
});

var plugins = [ defineEnvPlugin, new ExtractTextPlugin('style.[contenthash].css') ];
var entryScripts = ['babel-polyfill', './app/main.prod.js'];
var loaders = [
  // the JSX in tideline needs transpiling
  {test: /node_modules\/tideline\/.*\.js$/, exclude: /tideline\/node_modules/, loader: 'babel-loader'},
  {test: /\.gif$/, loader: 'url-loader?limit=100000&mimetype=image/gif'},
  {test: /\.jpg$/, loader: 'url-loader?limit=10000&mimetype=image/jpg'},
  {test: /\.png$/, loader: 'url-loader?limit=10000&mimetype=image/png'},
  {test: /\.svg$/, loader: 'url-loader?limit=10000&mimetype=image/svg+xml'},
  {test: /favicon\.ico$/, loader: 'file-loader?name=favicon.ico&limit=100000&mimetype=image/x-icon'},
  {test: /\.eot$/, loader: 'url-loader?limit=10000&mimetype=application/vnd.ms-fontobject'},
  {test: /\.woff$/, loader: 'url-loader?limit=10000&mimetype=application/font-woff'},
  {test: /\.ttf$/, loader: 'url-loader?limit=10000&mimetype=application/x-font-ttf'},
  {test: /\.json$/, loader: 'json-loader'}
];

var output = {
  path: path.join(__dirname, '/dist'),
  filename: 'bundle.js'
}

if (isDev) {
  output.publicPath = 'http://localhost:3000/';
  plugins.push(new webpack.HotModuleReplacementPlugin());
  entryScripts = [
    'babel-polyfill',
    'webpack-dev-server/client?http://localhost:3000',
    'webpack/hot/only-dev-server',
    './app/main.js'
  ];

  loaders.push({test: /\.less$/, loaders: ['style-loader', 'css-loader', 'less-loader']});
  loaders.push({test: /\.js$/, exclude: /(node_modules)/, loaders: ['babel-loader']});
} else {
  loaders.push({test: /\.less$/, loader: ExtractTextPlugin.extract('style-loader', 'css-loader!less-loader')});
  loaders.push({test: /\.js$/, exclude: /(node_modules)/, loaders: ['babel-loader']});
}

module.exports = {
  entry: entryScripts,
  output: output,
  module: {
    loaders: loaders,
  },
  // tideline DEV env variable only needs to be true in tideline local dev
  plugins: plugins,
  // resolves tideline's embedded React dependencies
  resolve: { fallback: path.join(__dirname, 'node_modules') },
  resolveLoader: { fallback: path.join(__dirname, 'node_modules') },
  devServer: {
    publicPath: output.publicPath,
    hot: true,
    historyApiFallback: true
  }
};
<commit_msg>add local node_modules as root realove path<commit_after>var path = require('path');
var webpack = require('webpack');
var ExtractTextPlugin = require('extract-text-webpack-plugin');

var isDev = (process.env.NODE_ENV === 'development');
// these values are required in the config.app.js file -- we can't use
// process.env with webpack, we have to create these magic constants
// individually.
var defineEnvPlugin = new webpack.DefinePlugin({
  __UPLOAD_API__: JSON.stringify(process.env.UPLOAD_API || null),
  __API_HOST__: JSON.stringify(process.env.API_HOST || null),
  __INVITE_KEY__: JSON.stringify(process.env.INVITE_KEY || null),
  __PASSWORD_MIN_LENGTH__: JSON.stringify(process.env.PASSWORD_MIN_LENGTH || null),
  __PASSWORD_MAX_LENGTH__: JSON.stringify(process.env.PASSWORD_MAX_LENGTH || null),
  __ABOUT_MAX_LENGTH__: JSON.stringify(process.env.ABOUT_MAX_LENGTH || null),
  __DEV__: isDev,
  __TEST__: false,
  __DEV_TOOLS__: (process.env.DEV_TOOLS != null) ? process.env.DEV_TOOLS : (isDev ? true : false)
});

var plugins = [ defineEnvPlugin, new ExtractTextPlugin('style.[contenthash].css') ];
var entryScripts = ['babel-polyfill', './app/main.prod.js'];
var loaders = [
  // the JSX in tideline needs transpiling
  {test: /node_modules\/tideline\/.*\.js$/, exclude: /tideline\/node_modules/, loader: 'babel-loader'},
  {test: /\.gif$/, loader: 'url-loader?limit=100000&mimetype=image/gif'},
  {test: /\.jpg$/, loader: 'url-loader?limit=10000&mimetype=image/jpg'},
  {test: /\.png$/, loader: 'url-loader?limit=10000&mimetype=image/png'},
  {test: /\.svg$/, loader: 'url-loader?limit=10000&mimetype=image/svg+xml'},
  {test: /favicon\.ico$/, loader: 'file-loader?name=favicon.ico&limit=100000&mimetype=image/x-icon'},
  {test: /\.eot$/, loader: 'url-loader?limit=10000&mimetype=application/vnd.ms-fontobject'},
  {test: /\.woff$/, loader: 'url-loader?limit=10000&mimetype=application/font-woff'},
  {test: /\.ttf$/, loader: 'url-loader?limit=10000&mimetype=application/x-font-ttf'},
  {test: /\.json$/, loader: 'json-loader'}
];

var output = {
  path: path.join(__dirname, '/dist'),
  filename: 'bundle.js'
}

if (isDev) {
  output.publicPath = 'http://localhost:3000/';
  plugins.push(new webpack.HotModuleReplacementPlugin());
  entryScripts = [
    'babel-polyfill',
    'webpack-dev-server/client?http://localhost:3000',
    'webpack/hot/only-dev-server',
    './app/main.js'
  ];

  loaders.push({test: /\.less$/, loaders: ['style-loader', 'css-loader', 'less-loader']});
  loaders.push({test: /\.js$/, exclude: /(node_modules)/, loaders: ['babel-loader']});
} else {
  loaders.push({test: /\.less$/, loader: ExtractTextPlugin.extract('style-loader', 'css-loader!less-loader')});
  loaders.push({test: /\.js$/, exclude: /(node_modules)/, loaders: ['babel-loader']});
}

module.exports = {
  entry: entryScripts,
  output: output,
  module: {
    loaders: loaders,
  },
  // tideline DEV env variable only needs to be true in tideline local dev
  plugins: plugins,
  // resolves tideline's embedded React dependencies
  resolve: {
    root: path.resolve('./node_modules'),
    fallback: path.join(__dirname, 'node_modules'),
  },
  resolveLoader: {
    root: path.resolve('./node_modules'),
    fallback: path.join(__dirname, 'node_modules'),
  },
  devServer: {
    publicPath: output.publicPath,
    hot: true,
    historyApiFallback: true
  }
};
<|endoftext|>


<commit_before>
/*!
 * string
 * JavaScript string utilities library
 * Copyright (c) 2011 Enrico Marino <enrico.marino@email.com>
 * MIT License
 */

 !(function (exports) {

  var undefined
    , toString = {}.toString
    ;

  exports.string = {};

  /**
   * Library version.
   */

  string.version = '0.1.0';

  /**
   * Test if 'self' is a string.
   *
   * @param {String} self string
   * @return {Boolean} true if 'self' is a string, false otherwise
   * @api public
   */

  string.is = function (self) {
    return '[object String]' === toString.call(self);
  };

  /**
   * Test if 'self' is blank.
   *
   * @param {String} self string
   * @return {Boolean} true if 'self' is blank, false otherwise
   * @api public
   */

  string.is.blank = function (self) {
    return !!self.match(/^\s*$/);
  };

  /**
   * Capitalize 'self'.
   *
   * @param {String} self string
   * @return {String} 'self' capitalized
   * @api public
   */

  string.capitalize = function (self) {
    return self.charAt(0).toUpperCase()
      + self.substring(1).toLowerCase();
  };

  /**
   * Chop 'self' by 'step'.
   *
   * @param {String} self string
   * @param {Number} step step
   * @return {Array} parts of 'self' chopped
   * @api public
   */

  string.chop = function (self, step) {
    var result = []
      , len = self.length
      , i;

    step || (step = len);

    for (i = 0; i < len; i += step) {
      result.push(self.slice(i, i + step));
    }

    return result;
  };

  /**
   * Count 'substr' occurrencies in 'self'.
   *
   * @param {String} self string
   * @param {String} substr substring
   * @return {Number} number of occurrencies of 'substr' in 'self'
   * @api public
   */

  string.count = function (self, substr) {
    var result = 0
      , len = self.length
      , step = substr.length
      , index = 0
      , i
      ;

    for (i = 0; i < len; i += index + step) {
      index = self.indexOf(substr, i);
      if (index < 0) {
        return result;
      }
      result += 1;
    }

    return result;
  };

  /**
   * Get chars of 'self'.
   *
   * @param {String} self string
   * @return {Array} chars of 'self'
   * @api public
   */

  string.chars = function (self) {
    return self.split('');
  };

  /**
   * Escape html.
   *
   * @param {String} self string
   * @return {String} string escaped
   * @api public
   */

  string.escapeHTML = function (self) {
    return self
      .replace(/&/g, '&')
      .replace(/</g, '<')
      .replace(/>/g, '>')
      .replace(/"/g, '"')
      .replace(/'/g, "'");
  };

  /**
   * Unescape html.
   *
   * @param {String} self string
   * @return {String} string unescaped
   * @api public
   */

  string.unescapeHTML = function (self) {

    return self
      .replace(/&/g, '&')
      .replace(/</g, '<')
      .replace(/>/g, '>')
      .replace(/"/g, '"')
      .replace(/'/g, "'");
  };

  /**
   * Escape regular expression.
   *
   * @param {String} self string
   * @return {String} string unescaped
   * @api public
   */

  string.escapeRegExp = function (self) {
    return self.replace(/([-.*+?^${}()|[\]\/\\])/g, '\\$1');
  };

  /**
   * Insert 'substr' in 'self' from the 'i'-th char.
   *
   * @param {String} self string
   * @param {String} substr substring
   * @param {Number} [i = self.length]
   * @return {String} 'self' with 'substr' inserted from the 'i'-th char
   * @api public
   */

  string.insert = function (self, substr, i) {
    i || (i = self.length);

    return self
      .split('')
      .splice(i, 0, substr)
      .join('');
  };

  /**
   * Test if 'self' includes 'substr'
   *
   * @param {String} self string
   * @param {String} substr substring
   * @return {Boolean} true if 'self' includes 'substr', false otherwise
   * @api public
   */

  string.includes = function (self, substr) {
    return self.indexOf(substr) !== -1;
  };

  /**
   * Return lines.
   *
   * @param {String} self string
   * @return {Array} lines.
   * @api public
   */

  string.lines = function (self) {
    return self.split('\n');
  };

  /**
   * Splice 'self'.
   *
   * @param {String} self string
   * @param {Number} i i
   * @param {Number} howmany how many
   * @param {String} substr sub string
   * @return {String} 'self' spliced
   * @api public
   */

  string.splice = function (self, i, howmany, substr) {
    return self
      .split('')
      .splice(i, howmany, substr)
      .join('');
  };

  /**
   * Test if 'self' starts with 'start'.
   *
   * @param {String} self string
   * @param {String} start start
   * @return {Boolean} true if 'self' starts with 'start', false otherwise.
   * @api public
   */

  string.startsWith = function (self, start) {
    return self.length >= start.length
      && self.substring(0, start.length) === start;
  };

  /**
   * Test if 'self' ends with 'end'.
   *
   * @param {String} self string
   * @param {String} end end
   * @return {Boolean} true if 'self' ends with 'end', false otherwise.
   * @api public
   */

  string.endsWith = function (self, ends) {
    return self.length >= ends.length
      && self.substring(self.length - end.length) === end;
  };

}(this));<commit_msg>added camelize<commit_after>
/*!
 * string
 * JavaScript string utilities library
 * Copyright (c) 2011 Enrico Marino <enrico.marino@email.com>
 * MIT License
 */

 !(function (exports) {

  var undefined
    , toString = {}.toString
    ;

  exports.string = {};

  /**
   * Library version.
   */

  string.version = '0.1.0';

  /**
   * Test if 'self' is a string.
   *
   * @param {String} self string
   * @return {Boolean} true if 'self' is a string, false otherwise
   * @api public
   */

  string.is = function (self) {
    return '[object String]' === toString.call(self);
  };

  /**
   * Test if 'self' is blank.
   *
   * @param {String} self string
   * @return {Boolean} true if 'self' is blank, false otherwise
   * @api public
   */

  string.is.blank = function (self) {
    return !!self.match(/^\s*$/);
  };

  /**
   * Capitalize 'self'.
   *
   * @param {String} self string
   * @return {String} 'self' capitalized
   * @api public
   */

  string.capitalize = function (self) {
    return self.charAt(0).toUpperCase()
      + self.substring(1).toLowerCase();
  };

  /**
   * Chop 'self' by 'step'.
   *
   * @param {String} self string
   * @param {Number} step step
   * @return {Array} parts of 'self' chopped
   * @api public
   */

  string.chop = function (self, step) {
    var result = []
      , len = self.length
      , i;

    step || (step = len);

    for (i = 0; i < len; i += step) {
      result.push(self.slice(i, i + step));
    }

    return result;
  };

  /**
   * Count 'substr' occurrencies in 'self'.
   *
   * @param {String} self string
   * @param {String} substr substring
   * @return {Number} number of occurrencies of 'substr' in 'self'
   * @api public
   */

  string.count = function (self, substr) {
    var result = 0
      , len = self.length
      , step = substr.length
      , index = 0
      , i
      ;

    for (i = 0; i < len; i += index + step) {
      index = self.indexOf(substr, i);
      if (index < 0) {
        return result;
      }
      result += 1;
    }

    return result;
  };

  /**
   * Get chars of 'self'.
   *
   * @param {String} self string
   * @return {Array} chars of 'self'
   * @api public
   */

  string.chars = function (self) {
    return self.split('');
  };

  /**
   * Escape html.
   *
   * @param {String} self string
   * @return {String} string escaped
   * @api public
   */

  string.escapeHTML = function (self) {
    return self
      .replace(/&/g, '&')
      .replace(/</g, '<')
      .replace(/>/g, '>')
      .replace(/"/g, '"')
      .replace(/'/g, "'");
  };

  /**
   * Unescape html.
   *
   * @param {String} self string
   * @return {String} string unescaped
   * @api public
   */

  string.unescapeHTML = function (self) {

    return self
      .replace(/&/g, '&')
      .replace(/</g, '<')
      .replace(/>/g, '>')
      .replace(/"/g, '"')
      .replace(/'/g, "'");
  };

  /**
   * Escape regular expression.
   *
   * @param {String} self string
   * @return {String} string unescaped
   * @api public
   */

  string.escapeRegExp = function (self) {
    return self.replace(/([-.*+?^${}()|[\]\/\\])/g, '\\$1');
  };

  /**
   * Insert 'substr' in 'self' from the 'i'-th char.
   *
   * @param {String} self string
   * @param {String} substr substring
   * @param {Number} [i = self.length]
   * @return {String} 'self' with 'substr' inserted from the 'i'-th char
   * @api public
   */

  string.insert = function (self, substr, i) {
    i || (i = self.length);

    return self
      .split('')
      .splice(i, 0, substr)
      .join('');
  };

  /**
   * Test if 'self' includes 'substr'
   *
   * @param {String} self string
   * @param {String} substr substring
   * @return {Boolean} true if 'self' includes 'substr', false otherwise
   * @api public
   */

  string.includes = function (self, substr) {
    return self.indexOf(substr) !== -1;
  };

  /**
   * Return lines.
   *
   * @param {String} self string
   * @return {Array} lines.
   * @api public
   */

  string.lines = function (self) {
    return self.split('\n');
  };

  /**
   * Splice 'self'.
   *
   * @param {String} self string
   * @param {Number} i i
   * @param {Number} howmany how many
   * @param {String} substr sub string
   * @return {String} 'self' spliced
   * @api public
   */

  string.splice = function (self, i, howmany, substr) {
    return self
      .split('')
      .splice(i, howmany, substr)
      .join('');
  };

  /**
   * Test if 'self' starts with 'start'.
   *
   * @param {String} self string
   * @param {String} start start
   * @return {Boolean} true if 'self' starts with 'start', false otherwise.
   * @api public
   */

  string.startsWith = function (self, start) {
    return self.length >= start.length
      && self.substring(0, start.length) === start;
  };

  /**
   * Test if 'self' ends with 'end'.
   *
   * @param {String} self string
   * @param {String} end end
   * @return {Boolean} true if 'self' ends with 'end', false otherwise.
   * @api public
   */

  string.endsWith = function (self, ends) {
    return self.length >= ends.length
      && self.substring(self.length - end.length) === end;
  };

  /**
   * Camelize 'self'.
   *
   * @param {String} self string
   * @return {String} 'self' camelized.
   * @api public
   */

  string.camelize = function (self) {
    return self
      .trim()
      .replace(/(\-|_|\s)+(.)?/g, function (match, separator, chr) {
        return chr ? chr.toUpperCase() : '';
      });
  };

}(this));<|endoftext|>


<commit_before>const path = require('path');

const ExtractTextPlugin = require('extract-text-webpack-plugin');
const webpack = require('webpack');

module.exports = {
  entry: {
    vendor: './src/vendor/index.js',
    mb: ['./src/mb/index.jsx', './src/mb/index.html']
  },
  output: {
    filename: 'assets/js/[name].js',
    chunkFilename: 'assets/js/chunk.[id].js',
    path: path.resolve(__dirname, 'public'),
    publicPath: '/'
  },
  devServer: {
    compress: true,
    hot: false,
    hotOnly: false,
    contentBase: path.resolve(__dirname, 'public'),
    watchContentBase: false,
    watchOptions: {
      poll: false
    },
    proxy: {
      '/api': {
        target: 'http://api.douban.com/v2',
        pathRewrite: {'^/api' : ''},
        changeOrigin: true,
      }
    }
  },
  resolve: {
    extensions: ['.js', '.jsx']
  },
  module: {
    rules: [
      {
        test: /\.jsx?$/,
        use: ['babel-loader'],
        exclude: /node_modules/
      },
      {
        test: /\.less$/,
        use: ExtractTextPlugin.extract({
          fallback: 'style-loader',
          use: ['css-loader', 'less-loader']
        })
      },
      {
        test: /\.css$/,
        use: ExtractTextPlugin.extract({
          use: ['css-loader'],
          fallback: 'style-loader'
        }),
        include: /node_modules/
      },
      {
        test: /\.jpg$/,
        use: ['url-loader?name=[path][name].[ext]&limit=10240']
      },
      {
        test: /\.png$/,
        use: ['url-loader?name=[path][name].[ext]&limit=10240']
      },
      {
        test: /\.(eot|svg|ttf|woff2?)$/,
        use: ['file-loader?name=assets/fonts/[name].[ext]']
      },
      {
        test: /\.html$/,
        use: [
          'file-loader?name=[name].html',
          'extract-loader',
          'html-loader'
        ]
      }
    ]
  },
  plugins: [
    new webpack.optimize.CommonsChunkPlugin({
      names: 'vendor'
    }),
    new webpack.ProvidePlugin({
      $: 'jquery'
    }),
    new ExtractTextPlugin('assets/css/[name].css')
  ]
};
<commit_msg>Change file loader path<commit_after>const path = require('path');

const ExtractTextPlugin = require('extract-text-webpack-plugin');
const webpack = require('webpack');

module.exports = {
  entry: {
    vendor: './src/vendor/index.js',
    mb: ['./src/mb/index.jsx', './src/mb/index.html']
  },
  output: {
    filename: 'assets/js/[name].js',
    chunkFilename: 'assets/js/chunk.[id].js',
    path: path.resolve(__dirname, 'public'),
    publicPath: '/'
  },
  devServer: {
    compress: true,
    hot: false,
    hotOnly: false,
    contentBase: path.resolve(__dirname, 'public'),
    watchContentBase: false,
    watchOptions: {
      poll: false
    },
    proxy: {
      '/api': {
        target: 'http://api.douban.com/v2',
        pathRewrite: {'^/api' : ''},
        changeOrigin: true,
      }
    }
  },
  resolve: {
    extensions: ['.js', '.jsx']
  },
  module: {
    rules: [
      {
        test: /\.jsx?$/,
        use: ['babel-loader'],
        exclude: /node_modules/
      },
      {
        test: /\.less$/,
        use: ExtractTextPlugin.extract({
          fallback: 'style-loader',
          use: ['css-loader', 'less-loader']
        })
      },
      {
        test: /\.css$/,
        use: ExtractTextPlugin.extract({
          use: ['css-loader'],
          fallback: 'style-loader'
        }),
        include: /node_modules/
      },
      {
        test: /\.jpg$/,
        use: ['url-loader?name=assets/images/[name].[ext]&limit=10240']
      },
      {
        test: /\.png$/,
        use: ['url-loader?name=assets/images/[name].[ext]&limit=10240']
      },
      {
        test: /\.(eot|svg|ttf|woff2?)$/,
        use: ['file-loader?name=assets/fonts/[name].[ext]']
      },
      {
        test: /\.html$/,
        use: [
          'file-loader?name=[name].html',
          'extract-loader',
          'html-loader'
        ]
      }
    ]
  },
  plugins: [
    new webpack.optimize.CommonsChunkPlugin({
      names: 'vendor'
    }),
    new webpack.ProvidePlugin({
      $: 'jquery'
    }),
    new ExtractTextPlugin('assets/css/[name].css')
  ]
};
<|endoftext|>


<commit_before>const path = require('path');
const BundleTracker = require('webpack-bundle-tracker');
const CommonsChunkPlugin = require('webpack/lib/optimize/CommonsChunkPlugin');

module.exports = {
  context: __dirname,
  devtool: 'eval-source-map',
  entry: {
    // Used to extract common libraries
    vendor: [
      'classnames', 'es6-promise', 'whatwg-fetch',
      'moment', 'react', 'react-bootstrap', 'react-dom',
    ],
    core: [
      './assets/js/core/index',
    ],
    dashboard_approval: [
      './assets/js/dashboard/approval/index',
    ],
    events_archive: [
      './assets/js/events/archive/index',
    ],
    frontpageEvents: [
      './assets/js/frontpage/events/index',
    ],
    frontpageArticles: [
      './assets/js/frontpage/articles/index',
    ],
    webshop: [
      './assets/js/webshop/index',
    ],
  },
  resolve: {
    root: path.resolve(__dirname, './assets/'),
  },
  output: {
    path: path.resolve('./assets/webpack_bundles/'),
    filename: '[name]-[hash].js',
  },
  module: {
    loaders: [
      {
        test: /\.js$/,
        exclude: /node_modules/,
        loaders: ['react-hot', 'babel'],
      },
      {
        test: /\.less$/,
        // loader: ExtractTextPlugin.extract(
        loader:
          'style-loader!' +
          'css-loader?sourceMap!' +
          'less-loader?sourceMap',
      },
      {
        test: /\.(eot|svg|ttf|woff|woff2)$/,
        loader: 'url-loader?limit=10000',
      },
    ],
  },
  plugins: [
    new CommonsChunkPlugin({
      names: ['vendor'],
      minChunks: Infinity,
    }),
    new BundleTracker({ filename: './webpack-stats.json' }),
  ],
};
<commit_msg>Remove accidental comment<commit_after>const path = require('path');
const BundleTracker = require('webpack-bundle-tracker');
const CommonsChunkPlugin = require('webpack/lib/optimize/CommonsChunkPlugin');

module.exports = {
  context: __dirname,
  devtool: 'eval-source-map',
  entry: {
    // Used to extract common libraries
    vendor: [
      'classnames', 'es6-promise', 'whatwg-fetch',
      'moment', 'react', 'react-bootstrap', 'react-dom',
    ],
    core: [
      './assets/js/core/index',
    ],
    dashboard_approval: [
      './assets/js/dashboard/approval/index',
    ],
    events_archive: [
      './assets/js/events/archive/index',
    ],
    frontpageEvents: [
      './assets/js/frontpage/events/index',
    ],
    frontpageArticles: [
      './assets/js/frontpage/articles/index',
    ],
    webshop: [
      './assets/js/webshop/index',
    ],
  },
  resolve: {
    root: path.resolve(__dirname, './assets/'),
  },
  output: {
    path: path.resolve('./assets/webpack_bundles/'),
    filename: '[name]-[hash].js',
  },
  module: {
    loaders: [
      {
        test: /\.js$/,
        exclude: /node_modules/,
        loaders: ['react-hot', 'babel'],
      },
      {
        test: /\.less$/,
        loader:
          'style-loader!' +
          'css-loader?sourceMap!' +
          'less-loader?sourceMap',
      },
      {
        test: /\.(eot|svg|ttf|woff|woff2)$/,
        loader: 'url-loader?limit=10000',
      },
    ],
  },
  plugins: [
    new CommonsChunkPlugin({
      names: ['vendor'],
      minChunks: Infinity,
    }),
    new BundleTracker({ filename: './webpack-stats.json' }),
  ],
};
<|endoftext|>


<commit_before>var UTIL = require('util'),
    Q = require('q'),
    SAX = require('sax'),
    JSAPI = require('./jsAPI');

/**
 * Convert SVG (XML) string to SVG-as-JS object.
 *
 * @module svg2js
 *
 * @param {String} svgdata input data
 * @param {Object} config sax xml parser config
 * @return {Object} output data deferred promise
 */
module.exports = function(svgdata, config) {

    var strict = config.strict;
    delete config.strict;

    var deferred = Q.defer(),
        sax = SAX.parser(strict, config),
        root = {},
        current = root,
        stack = [];

    function pushToContent(content) {

        content = new JSAPI.Nodes(content);

        (current.content = current.content || []).push(content);

        return content;

    }

    sax.ondoctype = function(doctype) {

        pushToContent({
            doctype: doctype
        });

    };

    sax.onprocessinginstruction = function(data) {

        pushToContent({
            processinginstruction: data
        });

    };

    sax.oncomment = function(comment) {

        pushToContent({
            comment: comment
        });

    };

    sax.oncdata = function(cdata) {

        pushToContent({
            cdata: cdata
        });

    };

    sax.onopentag = function(data) {

        var elem = {
            elem: data.name,
            prefix: data.prefix,
            local: data.local
        };

        if (Object.keys(data.attributes).length) {
            elem.attrs = {};

            for (var name in data.attributes) {
                elem.attrs[name] = {
                    name: name,
                    value: data.attributes[name].value,
                    prefix: data.attributes[name].prefix,
                    local: data.attributes[name].local
                };
            }
        }

        elem = pushToContent(elem);
        current = elem;

        stack.push(elem);

    };

    sax.ontext = function(text) {

        pushToContent({
            text: text
        });

    };

    sax.onclosetag = function() {

        stack.pop();
        current = stack[stack.length - 1];

    };

    sax.onerror = function(e) {

        UTIL.error(('\n\033[31m' + 'XML parser error:' + '\033[m' + ' something wrong with your svg file ("' + e.message + '")\n'));
        process.exit(1);

    }

    sax.onend = function() {

        deferred.resolve(root);

    };

    sax.write(svgdata).close();

    return deferred.promise;

};
<commit_msg>lib/svg2js: JSHint correction<commit_after>var UTIL = require('util'),
    Q = require('q'),
    SAX = require('sax'),
    JSAPI = require('./jsAPI');

/**
 * Convert SVG (XML) string to SVG-as-JS object.
 *
 * @module svg2js
 *
 * @param {String} svgdata input data
 * @param {Object} config sax xml parser config
 * @return {Object} output data deferred promise
 */
module.exports = function(svgdata, config) {

    var strict = config.strict;
    delete config.strict;

    var deferred = Q.defer(),
        sax = SAX.parser(strict, config),
        root = {},
        current = root,
        stack = [];

    function pushToContent(content) {

        content = new JSAPI.Nodes(content);

        (current.content = current.content || []).push(content);

        return content;

    }

    sax.ondoctype = function(doctype) {

        pushToContent({
            doctype: doctype
        });

    };

    sax.onprocessinginstruction = function(data) {

        pushToContent({
            processinginstruction: data
        });

    };

    sax.oncomment = function(comment) {

        pushToContent({
            comment: comment
        });

    };

    sax.oncdata = function(cdata) {

        pushToContent({
            cdata: cdata
        });

    };

    sax.onopentag = function(data) {

        var elem = {
            elem: data.name,
            prefix: data.prefix,
            local: data.local
        };

        if (Object.keys(data.attributes).length) {
            elem.attrs = {};

            for (var name in data.attributes) {
                elem.attrs[name] = {
                    name: name,
                    value: data.attributes[name].value,
                    prefix: data.attributes[name].prefix,
                    local: data.attributes[name].local
                };
            }
        }

        elem = pushToContent(elem);
        current = elem;

        stack.push(elem);

    };

    sax.ontext = function(text) {

        pushToContent({
            text: text
        });

    };

    sax.onclosetag = function() {

        stack.pop();
        current = stack[stack.length - 1];

    };

    sax.onerror = function(e) {

        UTIL.error(('\n\033[31m' + 'XML parser error:' + '\033[m' + ' something wrong with your svg file ("' + e.message + '")\n'));
        process.exit(1);

    };

    sax.onend = function() {

        deferred.resolve(root);

    };

    sax.write(svgdata).close();

    return deferred.promise;

};
<|endoftext|>


<commit_before>var MiniCssExtractPlugin = require('mini-css-extract-plugin');
var HtmlWebpackPlugin = require('html-webpack-plugin');
var ProgressBarPlugin = require('progress-bar-webpack-plugin');
var CopyWebpackPlugin = require('copy-webpack-plugin');
var ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');
var TerserPlugin = require('terser-webpack-plugin');
var { TypedCssModulesPlugin } = require('typed-css-modules-webpack-plugin');

var commit = '"unknown"';
var version = '"unknown"';
// Don't show COMMIT/VERSION on Heroku (crashes, because no git dir)
if (process.env.PATH.indexOf('heroku') === -1) {
    // show full git version
    var GitRevisionPlugin = require('git-revision-webpack-plugin');
    var gitRevisionPlugin = new GitRevisionPlugin({
        versionCommand: 'describe --always --tags --dirty',
    });
    commit = JSON.stringify(gitRevisionPlugin.commithash());
    version = JSON.stringify(gitRevisionPlugin.version());
}

function cleanAndValidateUrl(url) {
    if (typeof url === 'string') {
        // we need to support legacy configuration values
        console.log(url);
        if (/^http/.test(url) === false) {
            throw 'URLS MUST START WITH PROTOCOL';
        }
        let cleanAndValidateUrl = url.replace(/\/$/, ''); // get rid of trailing slashes
        return cleanAndValidateUrl;
    } else {
        throw `Not a url: ${url}`;
    }
}

const NODE_ENV = process.env.NODE_ENV || 'development';

var jsonFN = require('json-fn');

const dotenv = require('dotenv');

const webpack = require('webpack');
const path = require('path');

const join = path.join;
const resolve = path.resolve;

const isDev = NODE_ENV === 'development';
const isTest = NODE_ENV === 'test';

console.log('NODE_ENV', NODE_ENV);

// devServer config
const devHost = process.env.HOST || 'localhost';
const devPort = process.env.PORT || 3000;

const root = resolve(__dirname);
const src = join(root, 'src');
const modules = join(root, 'node_modules');
const common = join(src, 'common');
const dest = join(root, 'dist');
const css = join(src, 'styles');

const fontPath = 'reactapp/[hash].[ext]';
const imgPath = 'reactapp/images/[hash].[ext]';

const babelCacheFolder = process.env.BABEL_CACHE_FOLDER || false;

// we don't need sourcemaps on circleci
const sourceMap = process.env.DISABLE_SOURCEMAP ? false : 'source-map';

var routeComponentRegex = /routes\/([^\/]+\/?[^\/]+).js$/;

// extract number of cores, or boolean value from WEBPACK_PARALLEL env var
const parallel = isNaN(parseInt(process.env.WEBPACK_PARALLEL))
    ? process.env.WEBPACK_PARALLEL
    : parseInt(process.env.WEBPACK_PARALLEL);

var sassResourcesLoader = {
    loader: 'sass-resources-loader',
    options: {
        resources: [
            path.resolve(
                __dirname,
                'node_modules/bootstrap-sass/assets/stylesheets/bootstrap/_variables.scss'
            ),
            path.resolve(
                __dirname,
                'node_modules/bootstrap-sass/assets/stylesheets/bootstrap/_mixins'
            ),
            './src/globalStyles/variables.scss',
        ],
    },
};

var config = {
    stats: {
        colors: true,
    },

    entry: [`babel-polyfill`, `${path.join(src, 'appBootstrapper.jsx')}`],
    output: {
        path: path.resolve(__dirname, 'dist'),
        filename: 'reactapp/[name].app.js',
        chunkFilename: 'reactapp/[name].[chunkhash].chunk.js',
        // cssFilename: 'reactapp/app.css',
        // hash: false,
        publicPath: '/',
    },

    optimization: {
        minimizer: [
            new TerserPlugin({
                parallel,
            }),
        ],
    },

    resolve: {
        extensions: ['.js', '.jsx', '.json', '.ts', '.tsx'],

        alias: {
            css: join(src, 'styles'),
            containers: join(src, 'containers'),
            components: join(src, 'components'),
            utils: join(src, 'utils'),
            styles: join(src, 'styles'),
            pages: join(src, 'pages'),
            shared: join(src, 'shared'),
            pako: join(
                path.join(__dirname + '/node_modules/pako/dist/pako.es5.js')
            ),
        },
    },

    resolveLoader: {
        modules: [
            'node_modules',
            path.join(process.cwd(), 'node_modules'),
            path.resolve(__dirname, 'loaders'),
        ],
    },

    plugins: [
        new webpack.DefinePlugin({
            VERSION: version,
            COMMIT: commit,
            IS_DEV_MODE: isDev,
            ENV_CBIOPORTAL_URL: process.env.CBIOPORTAL_URL
                ? JSON.stringify(
                      cleanAndValidateUrl(process.env.CBIOPORTAL_URL)
                  )
                : '"replace_me_env_cbioportal_url"',
            ENV_GENOME_NEXUS_URL: process.env.GENOME_NEXUS_URL
                ? JSON.stringify(
                      cleanAndValidateUrl(process.env.GENOME_NEXUS_URL)
                  )
                : '"replace_me_env_genome_nexus_url"',
        }),
        new HtmlWebpackPlugin({ cache: false, template: 'my-index.ejs' }),
        new ProgressBarPlugin(),
        new webpack.DllReferencePlugin({
            context: join(root, '.'),
            manifest: require('./common-dist/common-manifest.json'),
        }),
        new CopyWebpackPlugin([
            { from: './common-dist', to: 'reactapp' },
            { from: './src/rootImages', to: 'images' },
            { from: './src/common', to: 'common' },
            {
                from: './src/globalStyles/prefixed-bootstrap.min.css',
                to: 'reactapp/prefixed-bootstrap.min.css',
            },
            {
                from: './src/shared/lib/data/reference_genome_hg19.json',
                to: 'reactapp/reference_genome_hg19.json',
            },
            {
                from: './src/shared/legacy/igv.min.js',
                to: 'reactapp/igv.min.js',
            },
            { from: './src/shared/legacy/igv.css', to: 'reactapp/igv.css' },
            {
                from: './src/globalStyles/prefixed-bootstrap.min.css.map',
                to: 'reactapp/prefixed-bootstrap.min.css.map',
            },
        ]), // destination is relative to dist directory
        new TypedCssModulesPlugin({
            globPattern: 'src/**/*.module.scss',
        }),
    ],

    module: {
        rules: [
            {
                test: /\.tsx?$/,
                use: [
                    {
                        loader: 'babel-loader',
                        options: {
                            presets: [
                                '@babel/preset-env',
                                '@babel/preset-react',
                            ],
                            plugins: ['syntax-dynamic-import'],

                            cacheDirectory: babelCacheFolder,
                        },
                    },
                    {
                        loader: 'ts-loader',
                        options: {
                            transpileOnly:
                                isDev || isTest || process.env.NETLIFY,
                        },
                    },
                ],
                exclude: /node_modules/,
            },
            {
                test: /\.(js|jsx|babel)$/,
                use: [
                    {
                        loader: 'babel-loader',
                        options: {
                            presets: [
                                '@babel/preset-env',
                                '@babel/preset-react',
                            ],
                        },
                    },
                ],
                exclude: function(modulePath) {
                    return (
                        /node_modules/.test(modulePath) &&
                        !/igv\.min/.test(modulePath)
                    );
                },
            },
            {
                test: /\.otf(\?\S*)?$/,
                use: [
                    {
                        loader: `url-loader`,
                        options: {
                            name: fontPath,
                            limit: 10000,
                        },
                    },
                ],
            },
            {
                test: /\.eot(\?\S*)?$/,
                use: [
                    {
                        loader: `url-loader`,
                        options: {
                            name: fontPath,
                            limit: 10000,
                        },
                    },
                ],
            },
            {
                test: /\.svg(\?\S*)?$/,
                use: [
                    {
                        loader: `url-loader`,
                        options: {
                            name: fontPath,
                            mimetype: 'image/svg+xml',
                            limit: 10000,
                        },
                    },
                ],
            },
            {
                test: /\.ttf(\?\S*)?$/,
                use: [
                    {
                        loader: `url-loader`,
                        options: {
                            name: fontPath,
                            mimetype: 'application/octet-stream',
                            limit: 10000,
                        },
                    },
                ],
            },
            {
                test: /\.woff2?(\?\S*)?$/,
                use: [
                    {
                        loader: `url-loader`,
                        options: {
                            name: fontPath,
                            mimetype: 'application/font-woff',
                            limit: 10000,
                        },
                    },
                ],
            },
            {
                test: /\.(jpe?g|png|gif)$/,
                use: [
                    {
                        loader: `url-loader`,
                        options: {
                            name: imgPath,
                            limit: 10000,
                        },
                    },
                ],
            },
            {
                test: /\.swf$/,
                use: [
                    {
                        loader: `file-loader`,
                        options: {
                            name: imgPath,
                        },
                    },
                ],
            },
            {
                test: /\.pdf$/,
                use: [
                    {
                        loader: `url-loader`,
                        options: {
                            name: imgPath,
                            limit: 1,
                        },
                    },
                ],
            },
            {
                test: /lodash/,
                use: [{ loader: 'imports-loader?define=>false' }],
            },
            {
                test: /\.js$/,
                enforce: 'pre',
                use: [
                    {
                        loader: 'source-map-loader',
                    },
                ],
                exclude: [/igv\.min/, /node_modules\/svg2pdf.js\//],
            },

            {
                test: require.resolve('3dmol'),
                // 3Dmol expects "this" to be the global context
                use: 'imports-loader?this=>window',
            },
        ],

        noParse: [/3Dmol-nojquery.js/, /jspdf/],
    },
    devServer: {
        static: {
            directory: path.resolve(__dirname, 'dist'),
        },
        hot: true,
        historyApiFallback: true,
        // TODO removed in favor of https://webpack.js.org/configuration/other-options/#infrastructurelogging
        // noInfo: false,
        // quiet: false,
        // lazy: false,
        https: false,
        host: 'localhost',
        headers: { 'Access-Control-Allow-Origin': '*' },
        allowedHosts: 'all',
        devMiddleware: {
            publicPath: '/',
            stats: 'errors-only',
        },
    },
};

// ENV variables
const dotEnvVars = dotenv.config();
const environmentEnv = dotenv.config({
    path: join(root, 'config', `${NODE_ENV}.config.js`),
    silent: true,
});
const envVariables = Object.assign({}, dotEnvVars, environmentEnv);

const defines = Object.keys(envVariables).reduce(
    (memo, key) => {
        const val = JSON.stringify(envVariables[key]);
        memo[`__${key.toUpperCase()}__`] = val;
        return memo;
    },
    {
        __NODE_ENV__: JSON.stringify(NODE_ENV),
        __DEBUG__: isDev,
    }
);

config.plugins = [
    new webpack.DefinePlugin(defines),
    new MiniCssExtractPlugin({
        filename: 'reactapp/styles.css',
        allChunks: true,
    }),
    new webpack.ProvidePlugin({
        $: 'jquery',
        jQuery: 'jquery',
    }),
].concat(config.plugins);
// END ENV variables

// include jquery when we load boostrap-sass
config.module.rules.push({
    test: /bootstrap-sass[\/\\]assets[\/\\]javascripts[\/\\]/,
    use: [
        {
            loader: 'imports-loader',
            options: {
                jQuery: 'jquery',
            },
        },
    ],
});

if (isDev) {
    //add for testwriter
    // config.module.rules.push(
    //     {
    //         test: /\.ts|tsx/,
    //         use:[{loader: 'testwriter'}]
    //     }
    // );
    // config.entry.push(`${path.join(src, 'testWriter.js')}`);
    // see https://github.com/webpack/webpack-dev-server/blob/master/migration-v4.md
    // config.plugins.push(new webpack.HotModuleReplacementPlugin());
}

if (isDev || isTest) {
    config.devtool = sourceMap;

    // in dev we don't want to load the twitter widget b/c it can block load of site
    config.resolve.alias['react-twitter-widgets'] = join(
        src,
        'shared/Empty.tsx'
    );

    config.plugins.push(new ForkTsCheckerWebpackPlugin());

    // css modules for any scss matching test
    config.module.rules.push({
        test: /\.module\.scss$/,
        use: [
            'style-loader',
            {
                loader: 'css-loader',
                options: {
                    modules: true,
                    importLoaders: 2,
                    localIdentName: '[name]__[local]__[hash:base64:5]',
                },
            },
            'sass-loader',
            sassResourcesLoader,
        ],
    });

    // IN DEV WE WANT TO LOAD CSS AND SCSS BUT NOT USE EXTRACT TEXT PLUGIN
    // STYLES WILL BE IN JS BUNDLE AND APPENDED TO DOM IN <STYLE> TAGS

    config.module.rules.push({
        test: /\.css$/,
        use: ['style-loader', 'css-loader'],
    });

    config.module.rules.push({
        test: /\.scss$/,
        exclude: /\.module\.scss/,
        use: ['style-loader', 'css-loader', 'sass-loader', sassResourcesLoader],
    });

    config.devServer.port = devPort;
    //config.devServer.hostname = devHost;

    // force hot module reloader to hit absolute path so it can load
    // from dev server
    config.output.publicPath = '//localhost:3000/';
} else {
    config.output.publicPath = '/';

    // css modules for any scss matching test
    config.module.rules.push({
        test: /\.module\.scss$/,
        use: [
            {
                loader: MiniCssExtractPlugin.loader,
                options: {
                    fallback: 'style-loader',
                },
            },
            {
                loader: 'css-loader',
                options: {
                    modules: true,
                    localIdentName: '[name]__[local]__[hash:base64:5]',
                },
            },
            'sass-loader',
            sassResourcesLoader,
        ],
    });

    config.module.rules.push({
        test: /\.scss$/,
        exclude: /\.module\.scss/,
        use: [
            {
                loader: MiniCssExtractPlugin.loader,
                options: {
                    fallback: 'style-loader',
                },
            },
            'css-loader',
            'sass-loader',
            sassResourcesLoader,
        ],
    });

    config.module.rules.push({
        test: /\.css/,
        use: [
            {
                loader: MiniCssExtractPlugin.loader,
                options: {
                    fallback: 'style-loader',
                },
            },
            'css-loader',
        ],
    });
}

// reduce logging to optize netlify build
if (process.env.BUILD_REPORT_ERRORS_ONLY === 'true') {
    config.stats = 'errors-only';
}

//config.entry.push('bootstrap-loader');
// END BOOTSTRAP LOADER

// Roots

config.resolve.modules = [src, common, './node_modules'];

// end Roots

// Testing
if (isTest) {
    config.externals = {
        'react/addons': true,
        'react/lib/ReactContext': true,
        'react/lib/ExecutionEnvironment': true,
    };

    config.module.noParse = /[/\\]sinon\.js/;
    config.resolve.alias.sinon = 'sinon/pkg/sinon';
}
// End Testing

module.exports = config;
<commit_msg>fix react spinkit undefined variable error<commit_after>var MiniCssExtractPlugin = require('mini-css-extract-plugin');
var HtmlWebpackPlugin = require('html-webpack-plugin');
var ProgressBarPlugin = require('progress-bar-webpack-plugin');
var CopyWebpackPlugin = require('copy-webpack-plugin');
var ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');
var TerserPlugin = require('terser-webpack-plugin');
var { TypedCssModulesPlugin } = require('typed-css-modules-webpack-plugin');

var commit = '"unknown"';
var version = '"unknown"';
// Don't show COMMIT/VERSION on Heroku (crashes, because no git dir)
if (process.env.PATH.indexOf('heroku') === -1) {
    // show full git version
    var GitRevisionPlugin = require('git-revision-webpack-plugin');
    var gitRevisionPlugin = new GitRevisionPlugin({
        versionCommand: 'describe --always --tags --dirty',
    });
    commit = JSON.stringify(gitRevisionPlugin.commithash());
    version = JSON.stringify(gitRevisionPlugin.version());
}

function cleanAndValidateUrl(url) {
    if (typeof url === 'string') {
        // we need to support legacy configuration values
        console.log(url);
        if (/^http/.test(url) === false) {
            throw 'URLS MUST START WITH PROTOCOL';
        }
        let cleanAndValidateUrl = url.replace(/\/$/, ''); // get rid of trailing slashes
        return cleanAndValidateUrl;
    } else {
        throw `Not a url: ${url}`;
    }
}

const NODE_ENV = process.env.NODE_ENV || 'development';

var jsonFN = require('json-fn');

const dotenv = require('dotenv');

const webpack = require('webpack');
const path = require('path');

const join = path.join;
const resolve = path.resolve;

const isDev = NODE_ENV === 'development';
const isTest = NODE_ENV === 'test';

console.log('NODE_ENV', NODE_ENV);

// devServer config
const devHost = process.env.HOST || 'localhost';
const devPort = process.env.PORT || 3000;

const root = resolve(__dirname);
const src = join(root, 'src');
const modules = join(root, 'node_modules');
const common = join(src, 'common');
const dest = join(root, 'dist');
const css = join(src, 'styles');

const fontPath = 'reactapp/[hash].[ext]';
const imgPath = 'reactapp/images/[hash].[ext]';

const babelCacheFolder = process.env.BABEL_CACHE_FOLDER || false;

// we don't need sourcemaps on circleci
const sourceMap = process.env.DISABLE_SOURCEMAP ? false : 'source-map';

var routeComponentRegex = /routes\/([^\/]+\/?[^\/]+).js$/;

// extract number of cores, or boolean value from WEBPACK_PARALLEL env var
const parallel = isNaN(parseInt(process.env.WEBPACK_PARALLEL))
    ? process.env.WEBPACK_PARALLEL
    : parseInt(process.env.WEBPACK_PARALLEL);

var sassResourcesLoader = {
    loader: 'sass-resources-loader',
    options: {
        resources: [
            path.resolve(
                __dirname,
                'node_modules/bootstrap-sass/assets/stylesheets/bootstrap/_variables.scss'
            ),
            path.resolve(
                __dirname,
                'node_modules/bootstrap-sass/assets/stylesheets/bootstrap/_mixins'
            ),
            './src/globalStyles/variables.scss',
        ],
    },
};

var config = {
    stats: {
        colors: true,
    },

    entry: [`babel-polyfill`, `${path.join(src, 'appBootstrapper.jsx')}`],
    output: {
        path: path.resolve(__dirname, 'dist'),
        filename: 'reactapp/[name].app.js',
        chunkFilename: 'reactapp/[name].[chunkhash].chunk.js',
        // cssFilename: 'reactapp/app.css',
        // hash: false,
        publicPath: '/',
    },

    optimization: {
        minimizer: [
            new TerserPlugin({
                parallel,
            }),
        ],
    },

    resolve: {
        extensions: ['.js', '.jsx', '.json', '.ts', '.tsx'],

        alias: {
            css: join(src, 'styles'),
            containers: join(src, 'containers'),
            components: join(src, 'components'),
            utils: join(src, 'utils'),
            styles: join(src, 'styles'),
            pages: join(src, 'pages'),
            shared: join(src, 'shared'),
            pako: join(
                path.join(__dirname + '/node_modules/pako/dist/pako.es5.js')
            ),
        },
    },

    resolveLoader: {
        modules: [
            'node_modules',
            path.join(process.cwd(), 'node_modules'),
            path.resolve(__dirname, 'loaders'),
        ],
    },

    plugins: [
        new webpack.DefinePlugin({
            VERSION: version,
            COMMIT: commit,
            IS_DEV_MODE: isDev,
            ENV_CBIOPORTAL_URL: process.env.CBIOPORTAL_URL
                ? JSON.stringify(
                      cleanAndValidateUrl(process.env.CBIOPORTAL_URL)
                  )
                : '"replace_me_env_cbioportal_url"',
            ENV_GENOME_NEXUS_URL: process.env.GENOME_NEXUS_URL
                ? JSON.stringify(
                      cleanAndValidateUrl(process.env.GENOME_NEXUS_URL)
                  )
                : '"replace_me_env_genome_nexus_url"',
        }),
        new HtmlWebpackPlugin({ cache: false, template: 'my-index.ejs' }),
        new ProgressBarPlugin(),
        new webpack.DllReferencePlugin({
            context: join(root, '.'),
            manifest: require('./common-dist/common-manifest.json'),
        }),
        new CopyWebpackPlugin([
            { from: './common-dist', to: 'reactapp' },
            { from: './src/rootImages', to: 'images' },
            { from: './src/common', to: 'common' },
            {
                from: './src/globalStyles/prefixed-bootstrap.min.css',
                to: 'reactapp/prefixed-bootstrap.min.css',
            },
            {
                from: './src/shared/lib/data/reference_genome_hg19.json',
                to: 'reactapp/reference_genome_hg19.json',
            },
            {
                from: './src/shared/legacy/igv.min.js',
                to: 'reactapp/igv.min.js',
            },
            { from: './src/shared/legacy/igv.css', to: 'reactapp/igv.css' },
            {
                from: './src/globalStyles/prefixed-bootstrap.min.css.map',
                to: 'reactapp/prefixed-bootstrap.min.css.map',
            },
        ]), // destination is relative to dist directory
        new TypedCssModulesPlugin({
            globPattern: 'src/**/*.module.scss',
        }),
    ],

    module: {
        rules: [
            {
                test: /\.tsx?$/,
                use: [
                    {
                        loader: 'babel-loader',
                        options: {
                            presets: [
                                '@babel/preset-env',
                                '@babel/preset-react',
                            ],
                            plugins: ['syntax-dynamic-import'],

                            cacheDirectory: babelCacheFolder,
                        },
                    },
                    {
                        loader: 'ts-loader',
                        options: {
                            transpileOnly:
                                isDev || isTest || process.env.NETLIFY,
                        },
                    },
                ],
                exclude: /node_modules/,
            },
            {
                test: /\.(js|jsx|babel)$/,
                use: [
                    {
                        loader: 'babel-loader',
                        options: {
                            presets: [
                                '@babel/preset-env',
                                '@babel/preset-react',
                            ],
                        },
                    },
                ],
                exclude: function(modulePath) {
                    return (
                        /node_modules/.test(modulePath) &&
                        !/igv\.min/.test(modulePath)
                    );
                },
            },
            {
                test: /\.otf(\?\S*)?$/,
                use: [
                    {
                        loader: `url-loader`,
                        options: {
                            name: fontPath,
                            limit: 10000,
                        },
                    },
                ],
            },
            {
                test: /\.eot(\?\S*)?$/,
                use: [
                    {
                        loader: `url-loader`,
                        options: {
                            name: fontPath,
                            limit: 10000,
                        },
                    },
                ],
            },
            {
                test: /\.svg(\?\S*)?$/,
                use: [
                    {
                        loader: `url-loader`,
                        options: {
                            name: fontPath,
                            mimetype: 'image/svg+xml',
                            limit: 10000,
                        },
                    },
                ],
            },
            {
                test: /\.ttf(\?\S*)?$/,
                use: [
                    {
                        loader: `url-loader`,
                        options: {
                            name: fontPath,
                            mimetype: 'application/octet-stream',
                            limit: 10000,
                        },
                    },
                ],
            },
            {
                test: /\.woff2?(\?\S*)?$/,
                use: [
                    {
                        loader: `url-loader`,
                        options: {
                            name: fontPath,
                            mimetype: 'application/font-woff',
                            limit: 10000,
                        },
                    },
                ],
            },
            {
                test: /\.(jpe?g|png|gif)$/,
                use: [
                    {
                        loader: `url-loader`,
                        options: {
                            name: imgPath,
                            limit: 10000,
                        },
                    },
                ],
            },
            {
                test: /\.swf$/,
                use: [
                    {
                        loader: `file-loader`,
                        options: {
                            name: imgPath,
                        },
                    },
                ],
            },
            {
                test: /\.pdf$/,
                use: [
                    {
                        loader: `url-loader`,
                        options: {
                            name: imgPath,
                            limit: 1,
                        },
                    },
                ],
            },
            {
                test: /lodash/,
                use: [{ loader: 'imports-loader?define=>false' }],
            },
            {
                test: /\.js$/,
                enforce: 'pre',
                use: [
                    {
                        loader: 'source-map-loader',
                    },
                ],
                exclude: [/igv\.min/, /node_modules\/svg2pdf.js\//],
            },

            {
                test: require.resolve('3dmol'),
                // 3Dmol expects "this" to be the global context
                use: 'imports-loader?this=>window',
            },
        ],

        noParse: [/3Dmol-nojquery.js/, /jspdf/],
    },
    devServer: {
        static: {
            directory: path.resolve(__dirname, 'dist'),
        },
        hot: true,
        historyApiFallback: true,
        // TODO removed in favor of https://webpack.js.org/configuration/other-options/#infrastructurelogging
        // noInfo: false,
        // quiet: false,
        // lazy: false,
        https: false,
        host: 'localhost',
        headers: { 'Access-Control-Allow-Origin': '*' },
        allowedHosts: 'all',
        devMiddleware: {
            publicPath: '/',
            stats: 'errors-only',
        },
    },
};

// ENV variables
const dotEnvVars = dotenv.config();
const environmentEnv = dotenv.config({
    path: join(root, 'config', `${NODE_ENV}.config.js`),
    silent: true,
});
const envVariables = Object.assign({}, dotEnvVars, environmentEnv);

const defines = Object.keys(envVariables).reduce(
    (memo, key) => {
        const val = JSON.stringify(envVariables[key]);
        memo[`__${key.toUpperCase()}__`] = val;
        return memo;
    },
    {
        __NODE_ENV__: JSON.stringify(NODE_ENV),
        __DEBUG__: isDev,
        'process.env.REACT_SPINKIT_NO_STYLES': false,
    }
);

config.plugins = [
    new webpack.DefinePlugin(defines),
    new MiniCssExtractPlugin({
        filename: 'reactapp/styles.css',
        allChunks: true,
    }),
    new webpack.ProvidePlugin({
        $: 'jquery',
        jQuery: 'jquery',
    }),
].concat(config.plugins);
// END ENV variables

// include jquery when we load boostrap-sass
config.module.rules.push({
    test: /bootstrap-sass[\/\\]assets[\/\\]javascripts[\/\\]/,
    use: [
        {
            loader: 'imports-loader',
            options: {
                jQuery: 'jquery',
            },
        },
    ],
});

if (isDev) {
    //add for testwriter
    // config.module.rules.push(
    //     {
    //         test: /\.ts|tsx/,
    //         use:[{loader: 'testwriter'}]
    //     }
    // );
    // config.entry.push(`${path.join(src, 'testWriter.js')}`);
    // see https://github.com/webpack/webpack-dev-server/blob/master/migration-v4.md
    // config.plugins.push(new webpack.HotModuleReplacementPlugin());
}

if (isDev || isTest) {
    config.devtool = sourceMap;

    // in dev we don't want to load the twitter widget b/c it can block load of site
    config.resolve.alias['react-twitter-widgets'] = join(
        src,
        'shared/Empty.tsx'
    );

    config.plugins.push(new ForkTsCheckerWebpackPlugin());

    // css modules for any scss matching test
    config.module.rules.push({
        test: /\.module\.scss$/,
        use: [
            'style-loader',
            {
                loader: 'css-loader',
                options: {
                    modules: true,
                    importLoaders: 2,
                    localIdentName: '[name]__[local]__[hash:base64:5]',
                },
            },
            'sass-loader',
            sassResourcesLoader,
        ],
    });

    // IN DEV WE WANT TO LOAD CSS AND SCSS BUT NOT USE EXTRACT TEXT PLUGIN
    // STYLES WILL BE IN JS BUNDLE AND APPENDED TO DOM IN <STYLE> TAGS

    config.module.rules.push({
        test: /\.css$/,
        use: ['style-loader', 'css-loader'],
    });

    config.module.rules.push({
        test: /\.scss$/,
        exclude: /\.module\.scss/,
        use: ['style-loader', 'css-loader', 'sass-loader', sassResourcesLoader],
    });

    config.devServer.port = devPort;
    //config.devServer.hostname = devHost;

    // force hot module reloader to hit absolute path so it can load
    // from dev server
    config.output.publicPath = '//localhost:3000/';
} else {
    config.output.publicPath = '/';

    // css modules for any scss matching test
    config.module.rules.push({
        test: /\.module\.scss$/,
        use: [
            {
                loader: MiniCssExtractPlugin.loader,
                options: {
                    fallback: 'style-loader',
                },
            },
            {
                loader: 'css-loader',
                options: {
                    modules: true,
                    localIdentName: '[name]__[local]__[hash:base64:5]',
                },
            },
            'sass-loader',
            sassResourcesLoader,
        ],
    });

    config.module.rules.push({
        test: /\.scss$/,
        exclude: /\.module\.scss/,
        use: [
            {
                loader: MiniCssExtractPlugin.loader,
                options: {
                    fallback: 'style-loader',
                },
            },
            'css-loader',
            'sass-loader',
            sassResourcesLoader,
        ],
    });

    config.module.rules.push({
        test: /\.css/,
        use: [
            {
                loader: MiniCssExtractPlugin.loader,
                options: {
                    fallback: 'style-loader',
                },
            },
            'css-loader',
        ],
    });
}

// reduce logging to optize netlify build
if (process.env.BUILD_REPORT_ERRORS_ONLY === 'true') {
    config.stats = 'errors-only';
}

//config.entry.push('bootstrap-loader');
// END BOOTSTRAP LOADER

// Roots

config.resolve.modules = [src, common, './node_modules'];

// end Roots

// Testing
if (isTest) {
    config.externals = {
        'react/addons': true,
        'react/lib/ReactContext': true,
        'react/lib/ExecutionEnvironment': true,
    };

    config.module.noParse = /[/\\]sinon\.js/;
    config.resolve.alias.sinon = 'sinon/pkg/sinon';
}
// End Testing

module.exports = config;
<|endoftext|>


<commit_before>var path = require("path");
var webpack = require("webpack");
var AssetsPlugin = require('assets-webpack-plugin');

// Ensure a FRONTEND_HOST is setup since we embed it in the assets.json file
if (!process.env.FRONTEND_HOST) {
  throw "No FRONTEND_HOST set";
}

// Ensure a NODE_ENV is also present
if (!process.env.NODE_ENV) {
  throw "No NODE_ENV set";
}

// The FRONTEND_HOST must end with a /
if (process.env.FRONTEND_HOST.slice(-1) !== "/") {
  throw "FRONTEND_HOST must end with a /";
}

var IS_PRODUCTION = (process.env.NODE_ENV === "production");

// Include a hash of the bundle in the name when we're building these files for
// production so we can use non-expiring caches for them.
//
// Also, if we used hashes in development, we'd be forever filling up our dist
// folder with every hashed version of files we've changed (webpack doesn't
// clean up after itself)
var filenameFormat;
var chunkFilename;
if (IS_PRODUCTION) {
  filenameFormat = "[name]-[chunkhash].js";
  chunkFilename = "[id]-[chunkhash].js";
} else {
  filenameFormat = "[name].js";
  chunkFilename = "[id].js";
}

// Toggle between the devtool if on prod/dev since cheap-module-eval-source-map
// is way faster for development.
var devTool = IS_PRODUCTION ? "source-map" : "cheap-module-eval-source-map";

var plugins = [
  // Only add the 'whatwg-fetch' plugin if the browser doesn't support it
  new webpack.ProvidePlugin({ 'fetch': 'imports?this=>global!exports?global.fetch!whatwg-fetch' }),

  // Split emojis, vendor javascript up. The loader JS doesn't have any modules
  // inside it, but since it's the last one, that's where Webpack will dump all
  // of it's bootstrapping JS. This file will change on every compilation.
  new webpack.optimize.CommonsChunkPlugin({
    names: ["emojis", "vendor", "loader"],
    minChunks: 2
  }),

  // After Webpack compilation, spit out a 'manifest.json' file with a mapping
  // of file name, to compiled name.
  new AssetsPlugin({
    path: path.join(__dirname, '..', 'dist'),
    filename: 'manifest.json'
  }),

  // By default, Webpack uses numerical ID's for it's internal module
  // identification. When you add a module, everything gets shift by 1, which
  // means you end up having a different 'vendor.js' file, if you changed a
  // module in 'app.js', since all the ID's are now +1. NamedModulesPlugin uses
  // the name of the plugin instead of a id, the only problem with this, is
  // that it bloats file size, because instead of "1" being the ID, it's now
  // "../../node_modules/react/index.js" or something. In saying that though,
  // after gzipping, it's not a real problem.
  new webpack.NamedModulesPlugin(),

  // Ensures only moments "en" package is included (saves 200kb in final compilation)
  new webpack.ContextReplacementPlugin(/moment[\/\\]locale$/, /en/),

  // When you set NODE_ENV=production, that only sets it for the Webpack NodeJS
  // environment. We need to also send the variable to the JS compilation
  // inside Babel, so packages like React know now to include development
  // helpers. Doing this greatly reduces file size, and makes React faster
  // since it doesn't have to do a ton of type checking (which it only does to
  // help developers with error messages)
  new webpack.DefinePlugin({
    'process.env': {
      'NODE_ENV': JSON.stringify(process.env.NODE_ENV)
    }
  })
];

var vendor_modules = [
  "babel-polyfill",
  "classnames",
  "deepmerge",
  "es6-error",
  "escape-html",
  "eventemitter3",
  "graphql",
  "graphql-relay",
  "history",
  "moment",
  "object-assign",
  "pusher-js",
  "react",
  "react-addons-pure-render-mixin",
  "react-addons-update",
  "react-document-title",
  "react-dom",
  "react-relay",
  "react-router",
  "react-router-relay",
  "whatwg-fetch"
];

// If we're building for production, minify the JS
if (IS_PRODUCTION) {
  // Don't pack react-type-snob in production
  plugins.push(new webpack.IgnorePlugin(/^react-type-snob$/));

  // Your basic, run-of-the-mill, JS uglifier
  plugins.push(new webpack.optimize.UglifyJsPlugin({
    output: {
      comments: false
    },
    compress: {
      warnings: false,
      screw_ie8: true
    }
  }));
}

if (process.env['BUGSNAG_JS_API_KEY']) {
  // Only load Bugsnag if configured
  vendor_modules.push("bugsnag-js");
}

module.exports = {
  context: __dirname,

  devtool: devTool,

  entry: {
    vendor: vendor_modules,
    emojis: [path.join(__dirname, '../app/emojis/buildkite.js'), path.join(__dirname, '../app/emojis/apple.js')],
    app: path.join(__dirname, '../app/app.js'),
    public: path.join(__dirname, '../app/public.js')
  },

  output: {
    filename: filenameFormat,
    chunkFilename: chunkFilename,
    path: path.join(__dirname, '..', 'dist'),
    publicPath: process.env.FRONTEND_HOST
  },

  module: {
    rules: [
      {
        test: /\.css$/i,
        use: [
          'style-loader',
          'css-loader',
          'postcss-loader'
        ]
      },
      {
        test: /\.js$/i,
        exclude: /node_modules/,
        use: [
          'babel'
        ]
      },
      {
        test: /\.mdx$/i,
        use: [
          'babel-loader',
          'markdown-component-loader?passElementProps=true'
        ]
      },
      {
        test: /\.(woff)$/i,
        use: [
          'url-loader?limit=8192'
        ]
      },
      {
        test: /\.(png|svg|jpg|gif)$/i,
        use: [
          'url-loader?limit=8192',
          'image-webpack?optimizationLevel=7&interlaced=false'
        ]
      }
    ]
  },

  plugins: plugins,

  postcss: function() {
    return [
      require("postcss-import")(),
      // require("postcss-url")(),
      require("postcss-cssnext")({ features: { rem: false } }),
      require('postcss-easings')(),
      // add your "plugins" here
      // ...
      // and if you want to compress,
      // just use css-loader option that already use cssnano under the hood
      require("postcss-browser-reporter")(),
      require("postcss-reporter")()
    ];
  }
};
<commit_msg>New options syntax<commit_after>var path = require("path");
var webpack = require("webpack");
var AssetsPlugin = require('assets-webpack-plugin');

// Ensure a FRONTEND_HOST is setup since we embed it in the assets.json file
if (!process.env.FRONTEND_HOST) {
  throw "No FRONTEND_HOST set";
}

// Ensure a NODE_ENV is also present
if (!process.env.NODE_ENV) {
  throw "No NODE_ENV set";
}

// The FRONTEND_HOST must end with a /
if (process.env.FRONTEND_HOST.slice(-1) !== "/") {
  throw "FRONTEND_HOST must end with a /";
}

var IS_PRODUCTION = (process.env.NODE_ENV === "production");

// Include a hash of the bundle in the name when we're building these files for
// production so we can use non-expiring caches for them.
//
// Also, if we used hashes in development, we'd be forever filling up our dist
// folder with every hashed version of files we've changed (webpack doesn't
// clean up after itself)
var filenameFormat;
var chunkFilename;
if (IS_PRODUCTION) {
  filenameFormat = "[name]-[chunkhash].js";
  chunkFilename = "[id]-[chunkhash].js";
} else {
  filenameFormat = "[name].js";
  chunkFilename = "[id].js";
}

// Toggle between the devtool if on prod/dev since cheap-module-eval-source-map
// is way faster for development.
var devTool = IS_PRODUCTION ? "source-map" : "cheap-module-eval-source-map";

var plugins = [
  // Only add the 'whatwg-fetch' plugin if the browser doesn't support it
  new webpack.ProvidePlugin({ 'fetch': 'imports?this=>global!exports?global.fetch!whatwg-fetch' }),

  // Split emojis, vendor javascript up. The loader JS doesn't have any modules
  // inside it, but since it's the last one, that's where Webpack will dump all
  // of it's bootstrapping JS. This file will change on every compilation.
  new webpack.optimize.CommonsChunkPlugin({
    names: ["emojis", "vendor", "loader"],
    minChunks: 2
  }),

  // After Webpack compilation, spit out a 'manifest.json' file with a mapping
  // of file name, to compiled name.
  new AssetsPlugin({
    path: path.join(__dirname, '..', 'dist'),
    filename: 'manifest.json'
  }),

  // By default, Webpack uses numerical ID's for it's internal module
  // identification. When you add a module, everything gets shift by 1, which
  // means you end up having a different 'vendor.js' file, if you changed a
  // module in 'app.js', since all the ID's are now +1. NamedModulesPlugin uses
  // the name of the plugin instead of a id, the only problem with this, is
  // that it bloats file size, because instead of "1" being the ID, it's now
  // "../../node_modules/react/index.js" or something. In saying that though,
  // after gzipping, it's not a real problem.
  new webpack.NamedModulesPlugin(),

  // Ensures only moments "en" package is included (saves 200kb in final compilation)
  new webpack.ContextReplacementPlugin(/moment[\/\\]locale$/, /en/),

  // When you set NODE_ENV=production, that only sets it for the Webpack NodeJS
  // environment. We need to also send the variable to the JS compilation
  // inside Babel, so packages like React know now to include development
  // helpers. Doing this greatly reduces file size, and makes React faster
  // since it doesn't have to do a ton of type checking (which it only does to
  // help developers with error messages)
  new webpack.DefinePlugin({
    'process.env': {
      'NODE_ENV': JSON.stringify(process.env.NODE_ENV)
    }
  })
];

var vendor_modules = [
  "babel-polyfill",
  "classnames",
  "deepmerge",
  "es6-error",
  "escape-html",
  "eventemitter3",
  "graphql",
  "graphql-relay",
  "history",
  "moment",
  "object-assign",
  "pusher-js",
  "react",
  "react-addons-pure-render-mixin",
  "react-addons-update",
  "react-document-title",
  "react-dom",
  "react-relay",
  "react-router",
  "react-router-relay",
  "whatwg-fetch"
];

// If we're building for production, minify the JS
if (IS_PRODUCTION) {
  // Don't pack react-type-snob in production
  plugins.push(new webpack.IgnorePlugin(/^react-type-snob$/));

  // Your basic, run-of-the-mill, JS uglifier
  plugins.push(new webpack.optimize.UglifyJsPlugin({
    output: {
      comments: false
    },
    compress: {
      warnings: false,
      screw_ie8: true
    }
  }));
}

if (process.env['BUGSNAG_JS_API_KEY']) {
  // Only load Bugsnag if configured
  vendor_modules.push("bugsnag-js");
}

module.exports = {
  context: __dirname,

  devtool: devTool,

  entry: {
    vendor: vendor_modules,
    emojis: [path.join(__dirname, '../app/emojis/buildkite.js'), path.join(__dirname, '../app/emojis/apple.js')],
    app: path.join(__dirname, '../app/app.js'),
    public: path.join(__dirname, '../app/public.js')
  },

  output: {
    filename: filenameFormat,
    chunkFilename: chunkFilename,
    path: path.join(__dirname, '..', 'dist'),
    publicPath: process.env.FRONTEND_HOST
  },

  module: {
    rules: [
      {
        test: /\.css$/i,
        use: [
          'style-loader',
          'css-loader',
          'postcss-loader'
        ]
      },
      {
        test: /\.js$/i,
        exclude: /node_modules/,
        use: [
          'babel'
        ]
      },
      {
        test: /\.mdx$/i,
        use: [
          'babel-loader',
          'markdown-component-loader?' + JSON.stringify({ passElementProps: true })
        ]
      },
      {
        test: /\.(woff)$/i,
        use: [
          'url-loader?' + JSON.stringify({ limit: 8192 })
        ]
      },
      {
        test: /\.(png|svg|jpg|gif)$/i,
        use: [
          'url-loader?' + JSON.stringify({ limit: 8192 }),
          'image-webpack?' + JSON.stringify({ optimizationLevel: 7, interlaced: false })
        ]
      }
    ]
  },

  plugins: plugins,

  postcss: function() {
    return [
      require("postcss-import")(),
      // require("postcss-url")(),
      require("postcss-cssnext")({ features: { rem: false } }),
      require('postcss-easings')(),
      // add your "plugins" here
      // ...
      // and if you want to compress,
      // just use css-loader option that already use cssnano under the hood
      require("postcss-browser-reporter")(),
      require("postcss-reporter")()
    ];
  }
};
<|endoftext|>


<commit_before>var gulp = require('gulp');

gulp.task('build', ['style-check', 'stylus', 'browserify']);
<commit_msg>disable style check<commit_after>var gulp = require('gulp');

gulp.task('build', ['stylus', 'browserify']);
<|endoftext|>


<commit_before>var numberInputBinding = {};
$.extend(numberInputBinding, textInputBinding, {
  find: function(scope) {
    return $(scope).find('input[type="number"]');
  },
  getValue: function(el) {
    var numberVal = $(el).val();
    if (/^\s*$/.test(numberVal))  // Return null if all whitespace
    return null;
    else if (!isNaN(numberVal))   // If valid Javascript number string, coerce to number
    return +numberVal;
    else
      return numberVal;           // If other string like "1e6", send it unchanged
  },
  setValue: function(el, value) {
    el.value = value;
  },
  getType: function(el) {
    return "shiny.number";
  },
  receiveMessage: function(el, data) {
    if (data.hasOwnProperty('min'))    el.min   = data.min;
    if (data.hasOwnProperty('max'))    el.max   = data.max;
    if (data.hasOwnProperty('step'))   el.step  = data.step;
    if (data.hasOwnProperty('value'))  el.value = data.value;

    if (data.hasOwnProperty('label'))
      $(el).parent().find('label[for="' + $escape(el.id) + '"]').text(data.label);

    $(el).trigger('change');
  },
  getState: function(el) {
    return { label: $(el).parent().find('label[for="' + $escape(el.id) + '"]').text(),
             value: this.getValue(el),
             min:   Number(el.min),
             max:   Number(el.max),
             step:  Number(el.step) };
  }
});
inputBindings.register(numberInputBinding, 'shiny.numberInput');<commit_msg>fix textInputBinding reference error<commit_after>var numberInputBinding = {};
$.extend(numberInputBinding, shiny.textInputBinding, {
  find: function(scope) {
    return $(scope).find('input[type="number"]');
  },
  getValue: function(el) {
    var numberVal = $(el).val();
    if (/^\s*$/.test(numberVal))  // Return null if all whitespace
    return null;
    else if (!isNaN(numberVal))   // If valid Javascript number string, coerce to number
    return +numberVal;
    else
      return numberVal;           // If other string like "1e6", send it unchanged
  },
  setValue: function(el, value) {
    el.value = value;
  },
  getType: function(el) {
    return "shiny.number";
  },
  receiveMessage: function(el, data) {
    if (data.hasOwnProperty('min'))    el.min   = data.min;
    if (data.hasOwnProperty('max'))    el.max   = data.max;
    if (data.hasOwnProperty('step'))   el.step  = data.step;
    if (data.hasOwnProperty('value'))  el.value = data.value;

    if (data.hasOwnProperty('label'))
      $(el).parent().find('label[for="' + $escape(el.id) + '"]').text(data.label);

    $(el).trigger('change');
  },
  getState: function(el) {
    return { label: $(el).parent().find('label[for="' + $escape(el.id) + '"]').text(),
             value: this.getValue(el),
             min:   Number(el.min),
             max:   Number(el.max),
             step:  Number(el.step) };
  }
});
inputBindings.register(numberInputBinding, 'shiny.numberInput');<|endoftext|>


<commit_before>var gulp = require('gulp');

gulp.task('watch', function() {
    gulp.watch('assets/less/layout.less', ['less'])
    gulp.watch('assets/js/**/*.js', ['js']);
});<commit_msg>Update watch.js<commit_after>var gulp = require('gulp');

gulp.task('watch', function() {
    gulp.watch('assets/less/**/*.less', ['less'])
    gulp.watch('assets/js/**/*.js', ['js']);
});
<|endoftext|>


<commit_before>/**
 * @module telize
 * @description Client for Telize API.
 * @version 1.0.0
 * @author Anatoliy Gatt [anatoliy.gatt@aol.com]
 * @copyright Copyright (c) 2015 Anatoliy Gatt
 * @license MIT
 */

"use strict";

/**
 * @private
 * @description Module dependencies.
 */

var http = require("http");
var freeze = require("deep-freeze-node");

/**
 * @private
 * @constant {String}
 * @description Module version.
 */

var VERSION = require('../package.json').version;

/**
 * @public
 * @constructor
 * @description Initialize instance of Telize with default request options.
 * @property {Object} defaultRequestOptions - Default request options.
 * @property {String} defaultRequestOptions.hostname - Default request hostname.
 * @property {Number} defaultRequestOptions.port - Default request port.
 * @property {String} defaultRequestOptions.basePath - Default request base path.
 */

function Telize() {
    this.defaultRequestOptions = {
        hostname: "www.telize.com",
        port: 80,
        basePath: ""
    };
}

/**
 * @public
 * @function getIP
 * @description Request current IP address.
 * @param {getIP~callback} callback - Callback when response comes in.
 */

Telize.prototype.getIP = function(callback) {
    if(!(typeof callback === "function") || !(callback instanceof Function)) {
        throw new Error("getIP() must have callback function");
    }

    request(this.defaultRequestOptions, "/jsonip", function(error, rawResponse) {
        if(!error) {
            try {
                var parsedResponse = JSON.parse(rawResponse);
            } catch(error) {
                callback(error, null);
            }
            callback(null, parsedResponse.ip);
        } else {
            callback(error, null);
        }
    });
};

/**
 * @callback getIP~callback
 * @description Use as callback in getIP function.
 * @param {Object} error - Generic error object.
 * @param {String} ip - IP address.
 */

/**
 * @public
 * @function getGeoIP
 * @description Request Geo IP data.
 * @param {String} [ip] - IP address.
 * @param {getGeoIP~callback} callback - Callback when response comes in.
 */

Telize.prototype.getGeoIP = function(ip, callback) {
    if((typeof ip === "function") || (ip instanceof Function)) {
        callback = ip;
        ip = undefined;
    } else if(!(typeof callback === "function") || !(callback instanceof Function)) {
        throw new Error("getGeoIP() must have callback function");
    }

    request(this.defaultRequestOptions, "/geoip" + (ip ? "/" + ip : ""), function(error, rawResponse) {
        if(!error) {
            try {
                var parsedResponse = JSON.parse(rawResponse);
            } catch(error) {
                callback(error, null);
            }
            if(parsedResponse.code && parsedResponse.message) {
                callback(new Error(parsedResponse.message, parsedResponse.code), null);
            }
            callback(null, parsedResponse);
        } else {
            callback(error, null);
        }
    });
};

/**
 * @callback getGeoIP~callback
 * @description Use as callback in getGeoIP function.
 * @param {Object} error - Generic error object.
 * @param {Object} data - Geo IP data object.
 */

/**
 * @private
 * @function request
 * @description Perform HTTP GET request.
 * @param options - Request options.
 * @param path - Request path.
 * @param {request~callback} callback - Callback when response comes in.
 */

function request(options, path, callback) {
    if(!(typeof options === "object") || !(options instanceof Object)) {
        throw new Error("request() must have options object");
    }
    if(!(typeof path === "string")) {
        throw new Error("request() must have path string");
    }
    if(!(typeof callback === "function") || !(callback instanceof Function)) {
        throw new Error("request() must have callback function");
    }

    var request = http.get({
        hostname: options.hostname,
        port: options.port,
        path: options.basePath + path,
        headers: {
            "Accept": "application/json",
            "Accept-Charset": "utf-8",
            "Accept-Encoding": "gzip, deflate",
            "Accept-Language": "en",
            "Accept-Datetime": new Date().toUTCString(),
            "Cache-Control": "no-cache",
            "Connection": "close",
            "Date": new Date().toUTCString(),
            "Host": options.hostname,
            "Max-Forwards": 1,
            "Pragma": "no-cache",
            "TE": "trailers, deflate",
            "User-Agent": "telize-node/" + VERSION
        },
        agent: false,
        keepAlive: false
    }, function(response) {
        var rawResponse = "";
        response.on("data", function(data) {
            rawResponse += data;
        });
        response.on("end", function() {
            callback(null, rawResponse);
        });
        response.on("error", function(error) {
            callback(error, null);
        });
    });
    request.on("error", function(error) {
        callback(error, null);
    });
}

/**
 * @callback request~callback
 * @description Use as callback in request function.
 * @param {Object} error - Generic error object.
 * @param {String} rawResponse - Raw response string.
 */

/**
 * @public
 * @description Expose unchangeable instance of Telize.
 * @returns {Object} - Unchangeable instance of Telize.
 */

module.exports = function() {
    return freeze(new Telize());
};<commit_msg>Update telize.js<commit_after>/**
 * @module telize
 * @description Client for Telize API.
 * @version 1.0.0
 * @author Anatoliy Gatt [anatoliy.gatt@aol.com]
 * @copyright Copyright (c) 2015 Anatoliy Gatt
 * @license MIT
 */

"use strict";

/**
 * @private
 * @description Module dependencies.
 */

var http = require("http");
var freeze = require("deep-freeze-node");

/**
 * @private
 * @constant {String}
 * @description Module version.
 */

var VERSION = require('../package.json').version;

/**
 * @public
 * @constructor
 * @description Initialize instance of Telize with default request options.
 * @property {Object} defaultRequestOptions - Default request options.
 * @property {String} defaultRequestOptions.hostname - Default request hostname.
 * @property {Number} defaultRequestOptions.port - Default request port.
 * @property {String} defaultRequestOptions.basePath - Default request base path.
 */

function Telize() {
    this.defaultRequestOptions = {
        hostname: "www.telize.com",
        port: 80,
        basePath: ""
    };
}

/**
 * @public
 * @function getIP
 * @description Request current IP address.
 * @param {getIP~callback} callback - Callback when response comes in.
 */

Telize.prototype.getIP = function(callback) {
    if(!(typeof callback === "function") || !(callback instanceof Function)) {
        throw new Error("getIP() must have callback function");
    }

    request(this.defaultRequestOptions, "/jsonip", function(error, rawResponse) {
        if(!error) {
            try {
                var parsedResponse = JSON.parse(rawResponse);
            } catch(error) {
                callback(error, null);
            }
            callback(null, parsedResponse.ip);
        } else {
            callback(error, null);
        }
    });
};

/**
 * @callback getIP~callback
 * @description Use as callback in getIP function.
 * @param {Object} error - Generic error object.
 * @param {String} ip - IP address.
 */

/**
 * @public
 * @function getGeoIP
 * @description Request Geo IP data.
 * @param {String} [ip] - IP address.
 * @param {getGeoIP~callback} callback - Callback when response comes in.
 */

Telize.prototype.getGeoIP = function(ip, callback) {
    if((typeof ip === "function") || (ip instanceof Function)) {
        callback = ip;
        ip = undefined;
    } else if(!(typeof callback === "function") || !(callback instanceof Function)) {
        throw new Error("getGeoIP() must have callback function");
    }

    request(this.defaultRequestOptions, "/geoip" + (ip ? "/" + ip : ""), function(error, rawResponse) {
        if(!error) {
            try {
                var parsedResponse = JSON.parse(rawResponse);
            } catch(error) {
                callback(error, null);
            }
            if(parsedResponse.code && parsedResponse.message) {
                callback(new Error(parsedResponse.message, parsedResponse.code), null);
            }
            callback(null, parsedResponse);
        } else {
            callback(error, null);
        }
    });
};

/**
 * @callback getGeoIP~callback
 * @description Use as callback in getGeoIP function.
 * @param {Object} error - Generic error object.
 * @param {Object} data - Geo IP data object.
 */

/**
 * @private
 * @function request
 * @description Perform HTTP GET request.
 * @param options - Request options.
 * @param path - Request path.
 * @param {request~callback} callback - Callback when response comes in.
 */

function request(options, path, callback) {
    if(!(typeof options === "object") || !(options instanceof Object)) {
        throw new Error("request() must have options object");
    }
    if(!(typeof path === "string")) {
        throw new Error("request() must have path string");
    }
    if(!(typeof callback === "function") || !(callback instanceof Function)) {
        throw new Error("request() must have callback function");
    }

    var request = http.get({
        hostname: options.hostname,
        port: options.port,
        path: options.basePath + path,
        headers: {
            "Accept": "application/json",
            "Accept-Charset": "utf-8",
            "Accept-Encoding": "*",
            "Accept-Language": "en",
            "Accept-Datetime": new Date().toUTCString(),
            "Cache-Control": "no-cache",
            "Connection": "close",
            "Date": new Date().toUTCString(),
            "Host": options.hostname,
            "Max-Forwards": 1,
            "Pragma": "no-cache",
            "TE": "trailers, deflate",
            "User-Agent": "telize-node/" + VERSION
        },
        agent: false,
        keepAlive: false
    }, function(response) {
        var rawResponse = "";
        response.on("data", function(data) {
            rawResponse += data;
        });
        response.on("end", function() {
            callback(null, rawResponse);
        });
        response.on("error", function(error) {
            callback(error, null);
        });
    });
    request.on("error", function(error) {
        callback(error, null);
    });
}

/**
 * @callback request~callback
 * @description Use as callback in request function.
 * @param {Object} error - Generic error object.
 * @param {String} rawResponse - Raw response string.
 */

/**
 * @public
 * @description Expose unchangeable instance of Telize.
 * @returns {Object} - Unchangeable instance of Telize.
 */

module.exports = function() {
    return freeze(new Telize());
};<|endoftext|>