<commit_before>var webpack = require('webpack')

module.exports = {
  entry: {
    ui: './lib/ui/main.js',
    vendor: ['react', 'debug', 'd3', 'react-bootstrap', 'bluebird', 'baconjs']
  },
  output: {
    path: 'dist',
    filename: '[name].js'
  },
  module: {
    loaders: [
      {test: /\.jsx?$/, exclude: /node_modules/, loader: 'babel'},
      {test: /\.json$/, loader: 'json'}
    ]
  },
  resolve: {
    alias: {
      bacon: "baconjs"
    }
  },
  plugins: [
    new webpack.optimize.CommonsChunkPlugin('vendor', 'vendor.js'),
    new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/)
  ]
}<commit_msg>Fix npm linked dependencies<commit_after>var webpack = require('webpack');
var path = require('path');

module.exports = {
  entry: {
    ui: './lib/ui/main.js',
    vendor: ['react', 'debug', 'd3', 'react-bootstrap', 'bluebird', 'baconjs']
  },
  output: {
    path: 'dist',
    filename: '[name].js'
  },
  module: {
    loaders: [
      {test: /\.jsx?$/, exclude: /node_modules/, loader: 'babel'},
      {test: /\.json$/, loader: 'json'}
    ]
  },
  resolve: {
    alias: {
      bacon: "baconjs"
    }
  },
  resolveLoader: { fallback: path.join(__dirname, "node_modules") },
  plugins: [
    new webpack.optimize.CommonsChunkPlugin('vendor', 'vendor.js'),
    new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/)
  ]
}
<|endoftext|>


<commit_before>/* eslint-env node */
var path = require('path');
var webpack = require('webpack');
var ExtractTextPlugin = require('extract-text-webpack-plugin');
var extractStyles = new ExtractTextPlugin('main.css');
var HtmlWebpackPlugin = require('html-webpack-plugin');

var externalAssets = {
  css: [
    'https://cdn.jsdelivr.net/bootstrap/2.3.2/css/bootstrap.min.css'
  ],
  js: [
    'http://cdn.jsdelivr.net/g/lodash@2.4.2(lodash.underscore.min.js),handlebarsjs@1.3.0,jquery@2.2.4,momentjs@2.9.0,bootstrap@2.3.2',
    'http://assets.zendesk.com/apps/sdk/2.0/zaf_sdk.js'
  ]
}

module.exports = {
  progress: true,
  entry: {
    app: ['./src/javascripts/index.js', './src/stylesheets/app.scss']
  },
  output: {
    path: './dist/assets',
    filename: 'main.js',
    sourceMapFilename: '[file].map'
  },
  module: {
    preLoaders: [
      {
        test: /\.js$/,
        exclude: /node_modules/,
        loader: 'eslint-loader'
      }
    ],
    loaders: [
      {
        test: /\.scss$/,
        loader: extractStyles.extract("style", ["css?sourceMap", "sass?sourceMap"])
      },
      {
        test: /\.json$/,
        exclude: /src\/translations\/.*\.json/,
        loader: 'json-loader'
      },
      {
        test: /src\/translations\/.*\.json/,
        loader: 'translations-loader'
      },
      {
        test: /\.js$/,
        exclude: /node_modules/,
        loader: 'babel-loader',
        query: {
          presets: ['es2015']
        }
      },
      {
        test: /\.(handlebars|hd?bs)$/,
        loader: 'handlebars-loader',
        query: {
          extensions: ['handlebars', 'hdbs', 'hbs'],
          runtime: 'handlebars'
        }
      }
    ]
  },
  resolveLoader: {
    modulesDirectories: [ './lib/loaders', 'node_modules' ]
  },
  resolve: {
    modulesDirectories: [ 'node_modules', './lib/javascripts' ],
    alias: {
      'app_manifest': path.join(__dirname, './dist/manifest.json')
    },
    extensions: ['', '.js']
  },
  externalAssets: externalAssets,
  externals: {
    handlebars: 'Handlebars',
    jquery: 'jQuery',
    lodash: '_',
    moment: 'moment',
    zendesk_app_framework_sdk: 'ZAFClient'
  },
  devtool: '#eval',
  plugins: [
    extractStyles,
    new HtmlWebpackPlugin({
      warning: 'AUTOMATICALLY GENERATED FROM ./lib/templates/layout.hdbs - DO NOT MODIFY THIS FILE DIRECTLY',
      vendorCss: externalAssets.css,
      vendorJs: externalAssets.js,
      template: './lib/templates/layout.hdbs'
    }),
    new webpack.optimize.UglifyJsPlugin({
      compress: {
        drop_debugger: false,
        warnings: false
      }
    })
  ]
};
<commit_msg>Switch to https for external assets so browsers don't cry about it<commit_after>/* eslint-env node */
var path = require('path');
var webpack = require('webpack');
var ExtractTextPlugin = require('extract-text-webpack-plugin');
var extractStyles = new ExtractTextPlugin('main.css');
var HtmlWebpackPlugin = require('html-webpack-plugin');

var externalAssets = {
  css: [
    'https://cdn.jsdelivr.net/bootstrap/2.3.2/css/bootstrap.min.css'
  ],
  js: [
    'https://cdn.jsdelivr.net/g/lodash@2.4.2(lodash.underscore.min.js),handlebarsjs@1.3.0,jquery@2.2.4,momentjs@2.9.0,bootstrap@2.3.2',
    'https://assets.zendesk.com/apps/sdk/2.0/zaf_sdk.js'
  ]
}

module.exports = {
  progress: true,
  entry: {
    app: ['./src/javascripts/index.js', './src/stylesheets/app.scss']
  },
  output: {
    path: './dist/assets',
    filename: 'main.js',
    sourceMapFilename: '[file].map'
  },
  module: {
    preLoaders: [
      {
        test: /\.js$/,
        exclude: /node_modules/,
        loader: 'eslint-loader'
      }
    ],
    loaders: [
      {
        test: /\.scss$/,
        loader: extractStyles.extract("style", ["css?sourceMap", "sass?sourceMap"])
      },
      {
        test: /\.json$/,
        exclude: /src\/translations\/.*\.json/,
        loader: 'json-loader'
      },
      {
        test: /src\/translations\/.*\.json/,
        loader: 'translations-loader'
      },
      {
        test: /\.js$/,
        exclude: /node_modules/,
        loader: 'babel-loader',
        query: {
          presets: ['es2015']
        }
      },
      {
        test: /\.(handlebars|hd?bs)$/,
        loader: 'handlebars-loader',
        query: {
          extensions: ['handlebars', 'hdbs', 'hbs'],
          runtime: 'handlebars'
        }
      }
    ]
  },
  resolveLoader: {
    modulesDirectories: [ './lib/loaders', 'node_modules' ]
  },
  resolve: {
    modulesDirectories: [ 'node_modules', './lib/javascripts' ],
    alias: {
      'app_manifest': path.join(__dirname, './dist/manifest.json')
    },
    extensions: ['', '.js']
  },
  externalAssets: externalAssets,
  externals: {
    handlebars: 'Handlebars',
    jquery: 'jQuery',
    lodash: '_',
    moment: 'moment',
    zendesk_app_framework_sdk: 'ZAFClient'
  },
  devtool: '#eval',
  plugins: [
    extractStyles,
    new HtmlWebpackPlugin({
      warning: 'AUTOMATICALLY GENERATED FROM ./lib/templates/layout.hdbs - DO NOT MODIFY THIS FILE DIRECTLY',
      vendorCss: externalAssets.css,
      vendorJs: externalAssets.js,
      template: './lib/templates/layout.hdbs'
    }),
    new webpack.optimize.UglifyJsPlugin({
      compress: {
        drop_debugger: false,
        warnings: false
      }
    })
  ]
};
<|endoftext|>


<commit_before>/**
 * Created by King Lee on 14-4-17.
 * some more about generic pool,read https://github.com/yuyunliuhen/node-pool.
 */
var fs = require('fs');
var redis = require('redis');
var generic_pool = require('generic-pool');

//  store the map of redis connect pool,{db_name:pool}
var pools = {};
var redis_count_statistics = 0;
function createRedisPool(db_name,config_file){
    var opts = {
        "no_ready_check" : config_file.proxy
    };
    // create a redis connection pool with
    // a max of config_file.max connections, and a config_file.idleTimeoutMillis second max idle time
    return generic_pool.Pool({
        name : db_name,
        dbIndex : 0,
        create : function(cb) {
            /**
             * create a new client connection. port defaults to 6379 and host defaults to 127.0.0.1.
             * If you have redis-server running on the same computer as node, then the defaults for port and host are probably fine.
             *
             * opts:no_ready_check: defaults to false. When a connection is established to the Redis server,
             * the server might still be loading the database from disk. While loading, the server not respond to any commands.
             * To work around this, node_redis has a "ready check" which sends the INFO command to the server.
             * The response from the INFO command indicates whether the server is ready for more commands.
             * When ready, node_redis emits a ready event. Setting no_ready_check to true will inhibit this check.
             */
            var client = redis.createClient(config_file.port, config_file.hostname, opts);
            client.on('error', function(err) {
                console.error('error at connect redis: %s', err.stack);
            });
            cb(null, client);
        },
        destroy : function(client) {
            if (!config_file.proxy) {
                client.quit();
            }
        },
        max : config_file.max,
        // optional. if you set this, make sure to drain() (see step 3)
        //  min      : 2,
        // specifies how long a resource can stay idle in pool before being removed
        idleTimeoutMillis : config_file.idleTimeoutMillis,
        // if true, logs via console.log - can also be a function
        log : true
    });
}

//  read config file and initialize generic pool
function initRedisPool(config_file) {
    for (var item in config_file) {
        var _pool = createRedisPool(item, config_file[item]);
        pools[item] = _pool;
    }
}

//  special the address of config file
function configure(config_file) {
    config_file = config_file || process.env.REDIS_CONFIG;

    if (typeof config_file === 'string') {
        config_file = JSON.parse(fs.readFileSync(config_file, 'utf8'));
    }

    if (config_file) {
        initRedisPool(config_file);
    }
}

//  do redis command
function execute(db_name, execb) {
    ++redis_count_statistics;
    var pool = pools[db_name];
    pool.acquire(function(err, client) {
        var release = function() { pool.release(client); };
        if (err) {
            console.error('error at execute command: %s', err.stack);
            release();
        } else {
            execb(client, release);
        }
    }, 0);
}

//  print current status info
function info() {
    return Object.keys(pools).map(function(k) {
        var item = pools[k];
        return {
            name : item.getName(),
            total : item.getPoolSize(),
            available : item.availableObjectsCount(),
            waiting : item.waitingClientsCount()
        };
    });
}

function show(){
    setInterval(function() {
        console.debug('redis pool is %j', info());
    }, 5000);
}

function get_redis_count_statistics() {
    return redis_count_statistics;
};

function reset_redis_count_statistics() {
    redis_count_statistics = 0;
};

//show();

module.exports = {
    configure : configure,
    execute : execute,
    info : info,
    get_redis_count_statistics:get_redis_count_statistics,
    reset_redis_count_statistics:reset_redis_count_statistics
};

<commit_msg>add statistis for redis<commit_after>/**
 * Created by King Lee on 14-4-17.
 * some more about generic pool,read https://github.com/yuyunliuhen/node-pool.
 */
var fs = require('fs');
var redis = require('redis');
var generic_pool = require('generic-pool');

//  store the map of redis connect pool,{db_name:pool}
var pools = {};
var redis_count_statistics = 0;
function createRedisPool(db_name,config_file){
    var opts = {
        "no_ready_check" : config_file.proxy
    };
    // create a redis connection pool with
    // a max of config_file.max connections, and a config_file.idleTimeoutMillis second max idle time
    return generic_pool.Pool({
        name : db_name,
        dbIndex : 0,
        create : function(cb) {
            /**
             * create a new client connection. port defaults to 6379 and host defaults to 127.0.0.1.
             * If you have redis-server running on the same computer as node, then the defaults for port and host are probably fine.
             *
             * opts:no_ready_check: defaults to false. When a connection is established to the Redis server,
             * the server might still be loading the database from disk. While loading, the server not respond to any commands.
             * To work around this, node_redis has a "ready check" which sends the INFO command to the server.
             * The response from the INFO command indicates whether the server is ready for more commands.
             * When ready, node_redis emits a ready event. Setting no_ready_check to true will inhibit this check.
             */
            var client = redis.createClient(config_file.port, config_file.hostname, opts);
            client.on('error', function(err) {
                console.error('error at connect redis: %s', err.stack);
            });
            cb(null, client);
        },
        destroy : function(client) {
            if (!config_file.proxy) {
                client.quit();
            }
        },
        max : config_file.max,
        // optional. if you set this, make sure to drain() (see step 3)
        //  min      : 2,
        // specifies how long a resource can stay idle in pool before being removed
        idleTimeoutMillis : config_file.idleTimeoutMillis,
        // if true, logs via console.log - can also be a function
        log : true
    });
}

//  read config file and initialize generic pool
function initRedisPool(config_file) {
    for (var item in config_file) {
        var _pool = createRedisPool(item, config_file[item]);
        pools[item] = _pool;
    }
}

//  special the address of config file
function configure(config_file) {
    config_file = config_file || process.env.REDIS_CONFIG;

    if (typeof config_file === 'string') {
        config_file = JSON.parse(fs.readFileSync(config_file, 'utf8'));
    }

    if (config_file) {
        initRedisPool(config_file);
    }
}

//  do redis command
function execute(db_name, execb) {
    ++redis_count_statistics;
    var pool = pools[db_name];
    pool.acquire(function(err, client) {
        var release = function() { pool.release(client); };
        if (err) {
            console.error('error at execute command: %s', err.stack);
            release();
        } else {
            execb(client, release);
        }
    }, 0);
}

//  print current status info
function info() {
    return Object.keys(pools).map(function(k) {
        var item = pools[k];
        return {
            name : item.getName(),
            total : item.getPoolSize(),
            available : item.availableObjectsCount(),
            waiting : item.waitingClientsCount()
        };
    });
}

function show(){
    setInterval(function() {
        console.debug('redis pool is %j', info());
    }, 5000);
}

function get_redis_count_statistics() {
    return redis_count_statistics;
}

function reset_redis_count_statistics() {
    redis_count_statistics = 0;
}

//show();

module.exports = {
    configure : configure,
    execute : execute,
    info : info,
    get_redis_count_statistics:get_redis_count_statistics,
    reset_redis_count_statistics:reset_redis_count_statistics
};

<|endoftext|>


<commit_before>var webpack = require('webpack')
var nodeExternals = require('webpack-node-externals')
var pkg = require('./package.json')

var nodeConfig = {
  devtool: 'source-map',
  entry: ['./src/index.js'],
  output: {
    path: './bin',
    filename: 'node.bundle.js',
    libraryTarget: 'commonjs2'
  },
  externals: [nodeExternals()],
  target: 'node',
  resolve: {
    extensions: ['', '.js']
  },
  module: {
    loaders: [{
      test: /\.js$/,
      loader: 'babel-loader',
      exclude: /node_modules/,
      query: {
        presets: ['latest', 'stage-0'],
        plugins: ['transform-object-rest-spread']
      }
    }, {
      test: /\.json$/,
      loader: "json-loader"
    }]
  }
}

var webConfig = {
  devtool: 'source-map',
  entry: ['./src/views/index.jsx'],
  output: {
    path: './bin',
    publicPath: '/js/modules/',
    filename: 'web.bundle.js',
    libraryTarget: 'assign',
    library: ['botpress', pkg.name]
  },
  resolve: {
    extensions: ['', '.js', '.jsx']
  },
  module: {
    loaders: [{
      test: /\.jsx?$/,
      loader: 'babel-loader',
      exclude: /node_modules/,
      query: {
        presets: ['latest', 'stage-0', 'react'],
        plugins: ['transform-object-rest-spread', 'transform-decorators-legacy']
      }
    }, {
      test: /\.scss$/,
      loaders: ['style', 'css?modules&importLoaders=1&localIdentName=[name]__[local]___[hash:base64:5]', 'sass']
    }, {
      test: /\.css$/,
      loaders: ['style', 'css']
    }, {
      test: /\.woff|\.woff2|\.svg|.eot|\.ttf/,
      loader: 'file?name=../fonts/[name].[ext]'
    }, {
      test: /\.json$/,
      loader: "json-loader"
    }]
  }
}

var compiler = webpack([nodeConfig, webConfig])
var postProcess = function(err, stats) {
  if (err) throw err
  console.log(stats.toString('minimal'))
}

if (process.argv.indexOf('--compile') !== -1) {
  compiler.run(postProcess)
} else if (process.argv.indexOf('--watch') !== -1) {
  compiler.watch(null, postProcess)
}

module.exports = {
  web: webConfig,
  node: nodeConfig
}
<commit_msg>Fixed conflicting module css modules<commit_after>var webpack = require('webpack')
var nodeExternals = require('webpack-node-externals')
var pkg = require('./package.json')

var nodeConfig = {
  devtool: 'source-map',
  entry: ['./src/index.js'],
  output: {
    path: './bin',
    filename: 'node.bundle.js',
    libraryTarget: 'commonjs2'
  },
  externals: [nodeExternals()],
  target: 'node',
  resolve: {
    extensions: ['', '.js']
  },
  module: {
    loaders: [{
      test: /\.js$/,
      loader: 'babel-loader',
      exclude: /node_modules/,
      query: {
        presets: ['latest', 'stage-0'],
        plugins: ['transform-object-rest-spread']
      }
    }, {
      test: /\.json$/,
      loader: 'json-loader'
    }]
  }
}

var webConfig = {
  devtool: 'source-map',
  entry: ['./src/views/index.jsx'],
  output: {
    path: './bin',
    publicPath: '/js/modules/',
    filename: 'web.bundle.js',
    libraryTarget: 'assign',
    library: ['botpress', pkg.name]
  },
  resolve: {
    extensions: ['', '.js', '.jsx']
  },
  module: {
    loaders: [{
      test: /\.jsx?$/,
      loader: 'babel-loader',
      exclude: /node_modules/,
      query: {
        presets: ['latest', 'stage-0', 'react'],
        plugins: ['transform-object-rest-spread', 'transform-decorators-legacy']
      }
    }, {
      test: /\.scss$/,
      loaders: ['style', 'css?modules&importLoaders=1&localIdentName=' + pkg.name + '__[name]__[local]___[hash:base64:5]', 'sass']
    }, {
      test: /\.css$/,
      loaders: ['style', 'css']
    }, {
      test: /\.woff|\.woff2|\.svg|.eot|\.ttf/,
      loader: 'file?name=../fonts/[name].[ext]'
    }, {
      test: /\.json$/,
      loader: 'json-loader'
    }]
  }
}

var compiler = webpack([nodeConfig, webConfig])
var postProcess = function(err, stats) {
  if (err) throw err
  console.log(stats.toString('minimal'))
}

if (process.argv.indexOf('--compile') !== -1) {
  compiler.run(postProcess)
} else if (process.argv.indexOf('--watch') !== -1) {
  compiler.watch(null, postProcess)
}

module.exports = {
  web: webConfig,
  node: nodeConfig
}
<|endoftext|>


<commit_before>
define (['jquery', 'facebook', 'analyze'], function ($, facebook, Analyze) {

    FB.init({
        appId      : '1468034890110746',
        xfbml      : true,
        status     : true,
        cookie     : true,
        version    : 'v2.2'
    });

    function checkLoginState() {
        FB.getLoginStatus(function (response) { statusChangeCallback(response); });
    }

    function statusChangeCallback(response) {
          if (response.status === 'connected') {
              location.href='/analyze';
          } else if (response.status === 'not_authorized') {
             FB.login(function(response) { statusChangeCallback(response); }, {scope: 'user_likes'});
          } else {
             alert("Please login.");
          }
    }

    function onStartClick () {
        checkLoginState();
        $('#start').animate({
            opacity:0
        },{
            duration: 1000,
            complete: function () {
                $('#start').hide();
                $('#loading').removeClass('hidden');
            }
        });

        Analyze.startAnalyzing();
    }

    // Attach callbacks
    $(document).ready(function () {
        $('#start').click(onStartClick);
    });

});<commit_msg>Single-page app. Cambios JS 2<commit_after>
define (['jquery', 'facebook', 'analyze'], function ($, facebook, Analyze) {

    FB.init({
        appId      : '1468034890110746',
        xfbml      : true,
        status     : true,
        cookie     : true,
        version    : 'v2.2'
    });

    function checkLoginState() {
        FB.getLoginStatus(function (response) { statusChangeCallback(response); });
    }

    function statusChangeCallback(response) {
          if (response.status === 'connected') {
              $.get('/analyze', function (res) {
                    console.log('res');
                    console.log(res);
                    Analyze.startAnalyzing();
                });
          } else if (response.status === 'not_authorized') {
             FB.login(function(response) { statusChangeCallback(response); }, {scope: 'user_likes'});
          } else {
             alert("Please login.");
          }
    }

    function onStartClick () {
        checkLoginState();
        $('#start').animate({
            opacity:0
        },{
            duration: 1000,
            complete: function () {
                $('#start').hide();
                $('#loading').removeClass('hidden');
            }
        });

    }

    // Attach callbacks
    $(document).ready(function () {
        $('#start').click(onStartClick);
    });

});<|endoftext|>


<commit_before>/*
  ONLY RUN BUILDS WITH `npm run web-dist`!
  DO NOT USE NORMAL WEBPACK! IT WILL NOT WORK!
*/

const webpack = require('webpack');
const createVariants = require('parallel-webpack').createVariants;
const version = require('./package.json').version;

const createConfig = (options) => {
  const plugins = [
    new webpack.DefinePlugin({ 'global.GENTLY': false }),
  ];

  if (options.minify) plugins.push(new webpack.optimize.UglifyJsPlugin({ minimize: true }));

  const filename = `./webpack/discord${process.env.VERSIONED === 'false' ? '' : '.' + version}${options.minify ? '.min' : ''}.js`; // eslint-disable-line

  return {
    entry: './src/index.js',
    output: {
      path: __dirname,
      filename,
    },
    module: {
      rules: [
        { test: /\.json$/, loader: 'json-loader' },
        { test: /\.md$/, loader: 'ignore-loader' },
      ],
    },
    node: {
      fs: 'empty',
      dns: 'mock',
      tls: 'mock',
      child_process: 'empty',
      dgram: 'empty',
      __dirname: true,
    },
    plugins,
  };
};

module.exports = createVariants({}, { minify: [false, true] }, createConfig);
<commit_msg>Ensure opusscript and node-opus don't get built<commit_after>/*
  ONLY RUN BUILDS WITH `npm run web-dist`!
  DO NOT USE NORMAL WEBPACK! IT WILL NOT WORK!
*/

const webpack = require('webpack');
const createVariants = require('parallel-webpack').createVariants;
const version = require('./package.json').version;

const createConfig = (options) => {
  const plugins = [
    new webpack.DefinePlugin({ 'global.GENTLY': false }),
  ];

  if (options.minify) plugins.push(new webpack.optimize.UglifyJsPlugin({ minimize: true }));

  const filename = `./webpack/discord${process.env.VERSIONED === 'false' ? '' : '.' + version}${options.minify ? '.min' : ''}.js`; // eslint-disable-line

  return {
    entry: './src/index.js',
    output: {
      path: __dirname,
      filename,
    },
    module: {
      rules: [
        { test: /\.json$/, loader: 'json-loader' },
        { test: /\.md$/, loader: 'ignore-loader' },
      ],
    },
    externals: {
      opusscript: { commonjs: 'opusscript' },
      'node-opus': { commonjs: 'node-opus' },
    },
    node: {
      fs: 'empty',
      dns: 'mock',
      tls: 'mock',
      child_process: 'empty',
      dgram: 'empty',
      __dirname: true,
    },
    plugins,
  };
};

module.exports = createVariants({}, { minify: [false, true] }, createConfig);
<|endoftext|>


<commit_before>const https = require('https')
const getJSON = require('get-json')
const fs = require('fs')

const getInstallerGeneratorUrl = async (fileName, appJSONUrl, os) => {
  const installerGeneratorUrl = `https://install.openfin.co/download/?config=${appJSONUrl}&fileName=${fileName}&os=${os}`;

  if (os === 'osx') {
    const appJSON = await getJSON(appJSONUrl)
    const appName = appJSON.startup_app.name
    const iconFile = appJSON.startup_app.applicationIcon
    return `${installerGeneratorUrl}&internal=true&appName=${appName}&iconFile=${iconFile}`
  }

  return `${installerGeneratorUrl}&unzipped=true`
}

const createInstaller = async (type, env, os = 'win') => {
  // maintain previous filenames for installers TODO: is this a requirement?
  const isLauncher = type === 'launcher'
  const fileName = `ReactiveTraderCloud${isLauncher ? '-launcher' : ''}-${env}`

  const appJSONUrl = `http://localhost:8080?type=${type}&env=${env}`
  const installerGeneratorUrl = await getInstallerGeneratorUrl(fileName, appJSONUrl, os)
  const extension = os === 'win' ? 'exe' : 'dmg'

  console.log(` - Generating installer: \x1b[36m${fileName}.${extension}\x1b[0m`)

  return new Promise(resolve => {
    https.get(installerGeneratorUrl, response => {
      const file = fs.createWriteStream(`install/${fileName}.${extension}`)
      response.pipe(file)
      resolve()
    })
  })
}

const createInstallers = installersData => {
  console.log(`Generating installers`)
  console.log(
    '\x1b[33m%s\x1b[0m', // Yellow
    `
NOTE: The installers contain just the URL to the manifest, not a copy of the manifest itself.
Make sure the files are available on their respective locations when distributing the installer.
`,
  )

  const installerDownloads = installersData.map(({ type, env, os })=> {
    return createInstaller(type, env, os)
  });

  return Promise.all(installerDownloads)
}

const INSTALLERS_TO_CREATE = [
  { type: 'app', env: 'dev', os: 'win' },
  { type: 'app', env: 'dev', os: 'osx' },
  { type: 'app', env: 'uat', os: 'win' },
  { type: 'app', env: 'uat', os: 'osx' },
  { type: 'app', env: 'demo', os: 'win' },
  { type: 'app', env: 'demo', os: 'osx' },
  { type: 'launcher', env: 'dev', os: 'win' },
  { type: 'launcher', env: 'uat', os: 'win' },
  { type: 'launcher', env: 'demo', os: 'win' }
]

createInstallers(INSTALLERS_TO_CREATE)

<commit_msg>feat(config): update installer config url [ARTP-877]<commit_after>const https = require('https')
const getJSON = require('get-json')
const fs = require('fs')

const getInstallerGeneratorUrl = async (fileName, appJSONUrl, os) => {
  const installerGeneratorUrl = `https://install.openfin.co/download/?config=${appJSONUrl}&fileName=${fileName}&os=${os}`;

  if (os === 'osx') {
    const appJSON = await getJSON(appJSONUrl)
    const appName = appJSON.startup_app.name
    const iconFile = appJSON.startup_app.applicationIcon
    return `${installerGeneratorUrl}&internal=true&appName=${appName}&iconFile=${iconFile}`
  }

  return `${installerGeneratorUrl}&unzipped=true`
}

const createInstaller = async (type, env, os = 'win') => {
  // maintain previous filenames for installers TODO: is this a requirement?
  const isLauncher = type === 'launcher'
  const fileName = `ReactiveTraderCloud${isLauncher ? '-launcher' : ''}-${env}`

  const appJSONUrl = `https://web-dev.adaptivecluster.com:8080?type=${type}&env=${env}`
  const installerGeneratorUrl = await getInstallerGeneratorUrl(fileName, appJSONUrl, os)
  const extension = os === 'win' ? 'exe' : 'dmg'

  console.log(` - Generating installer: \x1b[36m${fileName}.${extension}\x1b[0m`)

  return new Promise(resolve => {
    https.get(installerGeneratorUrl, response => {
      const file = fs.createWriteStream(`install/${fileName}.${extension}`)
      response.pipe(file)
      resolve()
    })
  })
}

const createInstallers = installersData => {
  console.log(`Generating installers`)
  console.log(
    '\x1b[33m%s\x1b[0m', // Yellow
    `
NOTE: The installers contain just the URL to the manifest, not a copy of the manifest itself.
Make sure the files are available on their respective locations when distributing the installer.
`,
  )

  const installerDownloads = installersData.map(({ type, env, os })=> {
    return createInstaller(type, env, os)
  });

  return Promise.all(installerDownloads)
}

const INSTALLERS_TO_CREATE = [
  { type: 'app', env: 'dev', os: 'win' },
  { type: 'app', env: 'dev', os: 'osx' },
  { type: 'app', env: 'uat', os: 'win' },
  { type: 'app', env: 'uat', os: 'osx' },
  { type: 'app', env: 'demo', os: 'win' },
  { type: 'app', env: 'demo', os: 'osx' },
  { type: 'launcher', env: 'dev', os: 'win' },
  { type: 'launcher', env: 'uat', os: 'win' },
  { type: 'launcher', env: 'demo', os: 'win' }
]

createInstallers(INSTALLERS_TO_CREATE)

<|endoftext|>


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

const context = path.join(__dirname, 'src')

const reactExternal = {
  root: 'React',
  commonjs2: 'react',
  commonjs: 'react',
  amd: 'react',
}

const reduxExternal = {
  root: 'Redux',
  commonjs2: 'redux',
  commonjs: 'redux',
  amd: 'redux',
}

const reactReduxExternal = {
  root: 'ReactRedux',
  commonjs2: 'react-redux',
  commonjs: 'react-redux',
  amd: 'react-redux',
}

module.exports = function(env) {
  const nodeEnv = process.env.NODE_ENV
  const isProd = nodeEnv === 'production'

  const plugins = [
    new webpack.DefinePlugin({
      'process.env': { NODE_ENV: JSON.stringify(nodeEnv) }
    }),
  ]

  if (isProd) {
    plugins.push(
      new webpack.LoaderOptionsPlugin({
        minimize: true,
        debug: false
      }),
      new webpack.optimize.UglifyJsPlugin({
        compress: {
          warnings: false,
          screw_ie8: true,
          conditionals: true,
          unused: true,
          comparisons: true,
          sequences: true,
          dead_code: true,
          evaluate: true,
          if_return: true,
          join_vars: true,
        },
        output: {
          comments: false,
        },
      })
    )
  }

  const filename = isProd ?
    './redux-filterlist.min.js' :
    './redux-filterlist.js'

  return {
    context,
    entry: './index.js',
    externals: {
      react: reactExternal,
      redux: reduxExternal,
      'react-redux': reactReduxExternal,
    },
    output: {
      path: path.join(__dirname, 'dist'),
      filename,
      library: 'ReduxFilterlist',
      libraryTarget: 'umd',
    },
    plugins,
    module: {
      rules: [{
        test: /(\.js)/,
        exclude: /node_modules/,
        use: [{
          loader: 'babel-loader',
          options: {
            presets: [
              ['env', { modules: false }],
              'react',
              'stage-2',
            ],
          },
        }],
      }],
    },
    resolve: {
      modules: [
        context,
        'node_modules',
      ],
      extensions: ['.js'],
    },
  }
}
<commit_msg>Removed webpack config<commit_after><|endoftext|>


<commit_before>var srcDir = __dirname + '/src/';
var distDir = __dirname + '/dist/';

var webpack = require('webpack');

var ExtractTextPlugin = require('extract-text-webpack-plugin');
var extractCSS = new ExtractTextPlugin('[name].css');

var dedupe = new webpack.optimize.DedupePlugin();

var uglify = new webpack.optimize.UglifyJsPlugin({
    //sourceMap: true,
    //mangle: true,
    output: {
        comments: false
    },
    compress: {
        warnings: false
    }
});

/* Build configuration for the application */
var applicationConfig = {
    context: srcDir,
    entry: {
        'nany': './index.js'
    },
    devtool: 'source-map',
    output: {
        path: distDir,
        filename: '[name].js',
        library: 'Nany',
        libraryTarget: 'umd',
        devtoolModuleFilenameTemplate: '[resource-path]'  // remove webpack:/// prefix
    },
    module: {
        loaders: [
            { test: /\.json$/, loader: 'json' },
            { test: /\.css$/, loader: extractCSS.extract('css-loader?sourceMap&modules&localIdentName=[local]---[hash:base64:5]') }
        ]
    },
    plugins: [
        extractCSS,
        dedupe,
        uglify
    ]
};

/* Build configuration for the tests */
var testsConfig = {
    context: srcDir,
    entry: {
        'nany.tests': ['./tests/index.js'],
        'nany.unittests': ['./tests/unit/index.js']
    },
    devtool: 'source-map',
    output: {
        path: distDir,
        filename: '[name].js',
        devtoolModuleFilenameTemplate: '[resource-path]'  // remove webpack:/// prefix
    },
    node: {
        fs: 'empty'  // needed to support tape
    },
    module: {
        loaders: [
            { test: /\.json$/, loader: 'json-loader' },
            { test: /\.html$/, loader: 'html-loader' },
            { test: /\.css$/, loader: 'css-loader' }  // we don't need CSS in tests / or use style-loader?
        ]
    }
};

module.exports = [applicationConfig, testsConfig];
<commit_msg>Reformatted the webpack config, windows compatible<commit_after>var path = require('path');
var webpack = require('webpack');
var ExtractTextPlugin = require('extract-text-webpack-plugin');

var root = __dirname;
var srcDir = path.join(root, 'src');
var distDir = path.join(root, 'dist');

var extractCSS = new ExtractTextPlugin('[name].css');
var dedupe = new webpack.optimize.DedupePlugin();
var uglify = new webpack.optimize.UglifyJsPlugin({
    //sourceMap: true,
    //mangle: true,
    output: {
        comments: false
    },
    compress: {
        warnings: false
    }
});

/* Build configuration for the application */
var applicationConfig = {
    context: srcDir,
    resolveLoader: {
        root: root
    },
    entry: {
        'nany': './index.js'
    },
    devtool: 'source-map',
    output: {
        path: distDir,
        filename: '[name].js',
        library: 'Nany',
        libraryTarget: 'umd',
        devtoolModuleFilenameTemplate: '[resource-path]'  // remove webpack:/// prefix
    },
    module: {
        loaders: [
            {
                test: /\.json$/,
                loader: 'json-loader'
            },
            {
                test: /\.css$/,
                loader: extractCSS.extract('css-loader?sourceMap&modules&localIdentName=[local]---[hash:base64:5]')
            }
        ]
    },
    plugins: [
        extractCSS,
        dedupe,
        uglify
    ]
};

/* Build configuration for the tests */
var testsConfig = {
    context: srcDir,
    resolveLoader: {
        root: root
    },
    entry: {
        'nany.tests': ['./tests/index.js'],
        'nany.unittests': ['./tests/unit/index.js']
    },
    devtool: 'source-map',
    output: {
        path: distDir,
        filename: '[name].js',
        devtoolModuleFilenameTemplate: '[resource-path]'  // remove webpack:/// prefix
    },
    node: {
        fs: 'empty'  // needed to support tape
    },
    module: {
        loaders: [
            {
                test: /\.json$/,
                loader: 'json-loader'
            },
            {
                test: /\.html$/,
                loader: 'html-loader'
            },
            {  // we don't need CSS in tests? or use style-loader?
                test: /\.css$/,
                loader: 'css-loader'
            }
        ]
    }
};

module.exports = [applicationConfig, testsConfig];
<|endoftext|>


<commit_before>const webpack = require('webpack')

module.exports = {

  output: {
    library: 'History',
    libraryTarget: 'umd'
  },

  module: {
    loaders: [
      { test: /\.js$/, exclude: /node_modules/, loader: 'babel' }
    ]
  },

  plugins: [
    new webpack.DefinePlugin({
      'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV || 'development')
    })
  ]

}
<commit_msg>Whitespace tweaks<commit_after>const webpack = require('webpack')

module.exports = {
  output: {
    library: 'History',
    libraryTarget: 'umd'
  },

  module: {
    loaders: [
      { test: /\.js$/, exclude: /node_modules/, loader: 'babel' }
    ]
  },

  plugins: [
    new webpack.DefinePlugin({
      'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV || 'development')
    })
  ]
}
<|endoftext|>


<commit_before>/**
 * Webpack config.
 *
 * Site Kit by Google, Copyright 2019 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     https://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/**
 * Node dependencies
 */
const fs = require( 'fs' );
const path = require( 'path' );

/**
 * External dependencies
 */
const MiniCssExtractPlugin = require( 'mini-css-extract-plugin' );
const TerserPlugin = require( 'terser-webpack-plugin' );
const { CleanWebpackPlugin } = require( 'clean-webpack-plugin' );
const WebpackBar = require( 'webpackbar' );
const { ProvidePlugin } = require( 'webpack' );

const projectPath = ( relativePath ) => {
	return path.resolve( fs.realpathSync( process.cwd() ), relativePath );
};

const noAMDParserRule = { parser: { amd: false } };

const siteKitExternals = {
	'googlesitekit-api': [ 'googlesitekit', 'api' ],
	'googlesitekit-data': [ 'googlesitekit', 'data' ],
	'googlesitekit-modules': [ 'googlesitekit', 'modules' ],
};

const externals = { ...siteKitExternals };

const rules = [
	noAMDParserRule,
	{
		test: /\.js$/,
		exclude: /node_modules/,
		use: [
			{
				loader: 'babel-loader',
				query: {
					presets: [ [ '@babel/env', {
						useBuiltIns: 'entry',
						corejs: 2,
					} ], '@babel/preset-react' ],
				},
			},
			{
				loader: 'eslint-loader',
				options: {
					quiet: true,
					formatter: require( 'eslint' ).CLIEngine.getFormatter( 'stylish' ),
				},
			},
		],
		...noAMDParserRule,
	},
];

const resolve = {
	alias: {
		'@wordpress/api-fetch__non-shim': require.resolve( '@wordpress/api-fetch' ),
		'@wordpress/api-fetch$': path.resolve( 'assets/js/api-fetch-shim.js' ),
		SiteKitCore: path.resolve( 'assets/js/' ),
		GoogleComponents: path.resolve( 'assets/js/components/' ),
		GoogleUtil: path.resolve( 'assets/js/util/' ),
		GoogleModules: path.resolve( './assets/js/modules/' ),
	},
	modules: [ projectPath( '.' ), 'node_modules' ],
};

const webpackConfig = ( mode ) => {
	return [
		// Build the settings js..
		{
			entry: {
				// New Modules (Post-JSR).
				'googlesitekit-api': './assets/js/googlesitekit-api.js',
				'googlesitekit-data': './assets/js/googlesitekit-data.js',
				'googlesitekit-datastore-site': './assets/js/googlesitekit-datastore-site.js',
				'googlesitekit-modules': './assets/js/googlesitekit-modules.js', // TODO: Add external following 1162.
				// Old Modules
				'googlesitekit-activation': './assets/js/googlesitekit-activation.js',
				'googlesitekit-settings': './assets/js/googlesitekit-settings.js',
				'googlesitekit-dashboard': './assets/js/googlesitekit-dashboard.js',
				'googlesitekit-dashboard-details': './assets/js/googlesitekit-dashboard-details.js',
				'googlesitekit-dashboard-splash': './assets/js/googlesitekit-dashboard-splash.js',
				'googlesitekit-wp-dashboard': './assets/js/googlesitekit-wp-dashboard.js',
				'googlesitekit-adminbar-loader': './assets/js/googlesitekit-adminbar-loader.js',
				'googlesitekit-admin': './assets/js/googlesitekit-admin.js',
				'googlesitekit-module': './assets/js/googlesitekit-module.js',
				// Needed to test if a browser extension blocks this by naming convention.
				ads: './assets/js/ads.js',
			},
			externals,
			output: {
				filename: '[name].js',
				path: __dirname + '/dist/assets/js',
				chunkFilename: '[name]-[chunkhash].js',
				publicPath: '',
			},
			performance: {
				maxEntrypointSize: 175000,
			},
			module: {
				rules,
			},
			plugins: [
				new ProvidePlugin( {
					React: 'react',
				} ),
				new WebpackBar( {
					name: 'Module Entry Points',
					color: '#fbbc05',
				} ),
				new CleanWebpackPlugin( {
				// Prevent this build from removing files created by one of the other builds
				// (eg. Plugin CSS and Test files).
					cleanOnceBeforeBuildPatterns: [],
				} ),
			],
			optimization: {
				minimizer: [
					new TerserPlugin( {
						parallel: true,
						sourceMap: false,
						cache: true,
						terserOptions: {
							// We preserve function names that start with capital letters as
							// they're _likely_ component names, and these are useful to have
							// in tracebacks and error messages.
							keep_fnames: /__|_x|_n|_nx|sprintf|^[A-Z].+$/,
							output: {
								comments: /translators:/i,
							},
						},
						extractComments: false,
					} ),
				],
			},
			resolve,
		},

		// Build the main plugin admin css.
		{
			entry: {
				admin: './assets/sass/admin.scss',
				adminbar: './assets/sass/adminbar.scss',
				wpdashboard: './assets/sass/wpdashboard.scss',
			},
			module: {
				rules: [
					{
						test: /\.scss$/,
						use: [
							MiniCssExtractPlugin.loader,
							{
								loader: 'css-loader',
								options: {
									minimize: ( 'production' === mode ),
								},
							},
							'postcss-loader',
							{
								loader: 'sass-loader',
								options: {
									includePaths: [ 'node_modules' ],
								},
							},
						],
					},
					{
						test: /\.(png|woff|woff2|eot|ttf|svg|gif)$/,
						use: { loader: 'url-loader?limit=100000' },
					},
				],
			},
			plugins: [
				new MiniCssExtractPlugin( {
					filename: '/assets/css/[name].css',
				} ),
				new WebpackBar( {
					name: 'Plugin CSS',
					color: '#4285f4',
				} ),
				new CleanWebpackPlugin( {
				// Prevent this build from removing files created by one of the other builds
				// (eg. Module Entry Points and Test files).
					cleanOnceBeforeBuildPatterns: [],
				} ),
			],
		},
	];
};

const testBundle = () => {
	return {
		entry: {
			'googlesitekit-tests': './assets/js/googlesitekit-tests.js',
			'e2e-utilities': './tests/e2e/e2e-utilities.js',
		},
		output: {
			filename: '[name].js',
			path: __dirname + '/dist/assets/js',
			chunkFilename: '[name].js',
			publicPath: '',
		},
		module: {
			rules,
		},
		plugins: [
			new WebpackBar( {
				name: 'Test files',
				color: '#34a853',
			} ),
			new CleanWebpackPlugin( {
				// Prevent this build from removing files created by one of the other builds
				// (eg. Module Entry Points and Plugin CSS).
				cleanOnceBeforeBuildPatterns: [],
			} ),
		],
		externals,
		resolve,
	};
};

module.exports = ( ...args ) => {
	const { includeTests, mode } = args[ 1 ];
	const config = webpackConfig( mode );

	if ( mode !== 'production' || includeTests ) {
		// Build the test files if we aren't doing a production build.
		config.push( testBundle() );
	}

	return config;
};
<commit_msg>Tweak comment whitespace<commit_after>/**
 * Webpack config.
 *
 * Site Kit by Google, Copyright 2019 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     https://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/**
 * Node dependencies
 */
const fs = require( 'fs' );
const path = require( 'path' );

/**
 * External dependencies
 */
const MiniCssExtractPlugin = require( 'mini-css-extract-plugin' );
const TerserPlugin = require( 'terser-webpack-plugin' );
const { CleanWebpackPlugin } = require( 'clean-webpack-plugin' );
const WebpackBar = require( 'webpackbar' );
const { ProvidePlugin } = require( 'webpack' );

const projectPath = ( relativePath ) => {
	return path.resolve( fs.realpathSync( process.cwd() ), relativePath );
};

const noAMDParserRule = { parser: { amd: false } };

const siteKitExternals = {
	'googlesitekit-api': [ 'googlesitekit', 'api' ],
	'googlesitekit-data': [ 'googlesitekit', 'data' ],
	'googlesitekit-modules': [ 'googlesitekit', 'modules' ],
};

const externals = { ...siteKitExternals };

const rules = [
	noAMDParserRule,
	{
		test: /\.js$/,
		exclude: /node_modules/,
		use: [
			{
				loader: 'babel-loader',
				query: {
					presets: [ [ '@babel/env', {
						useBuiltIns: 'entry',
						corejs: 2,
					} ], '@babel/preset-react' ],
				},
			},
			{
				loader: 'eslint-loader',
				options: {
					quiet: true,
					formatter: require( 'eslint' ).CLIEngine.getFormatter( 'stylish' ),
				},
			},
		],
		...noAMDParserRule,
	},
];

const resolve = {
	alias: {
		'@wordpress/api-fetch__non-shim': require.resolve( '@wordpress/api-fetch' ),
		'@wordpress/api-fetch$': path.resolve( 'assets/js/api-fetch-shim.js' ),
		SiteKitCore: path.resolve( 'assets/js/' ),
		GoogleComponents: path.resolve( 'assets/js/components/' ),
		GoogleUtil: path.resolve( 'assets/js/util/' ),
		GoogleModules: path.resolve( './assets/js/modules/' ),
	},
	modules: [ projectPath( '.' ), 'node_modules' ],
};

const webpackConfig = ( mode ) => {
	return [
		// Build the settings js..
		{
			entry: {
				// New Modules (Post-JSR).
				'googlesitekit-api': './assets/js/googlesitekit-api.js',
				'googlesitekit-data': './assets/js/googlesitekit-data.js',
				'googlesitekit-datastore-site': './assets/js/googlesitekit-datastore-site.js',
				'googlesitekit-modules': './assets/js/googlesitekit-modules.js', // TODO: Add external following 1162.
				// Old Modules
				'googlesitekit-activation': './assets/js/googlesitekit-activation.js',
				'googlesitekit-settings': './assets/js/googlesitekit-settings.js',
				'googlesitekit-dashboard': './assets/js/googlesitekit-dashboard.js',
				'googlesitekit-dashboard-details': './assets/js/googlesitekit-dashboard-details.js',
				'googlesitekit-dashboard-splash': './assets/js/googlesitekit-dashboard-splash.js',
				'googlesitekit-wp-dashboard': './assets/js/googlesitekit-wp-dashboard.js',
				'googlesitekit-adminbar-loader': './assets/js/googlesitekit-adminbar-loader.js',
				'googlesitekit-admin': './assets/js/googlesitekit-admin.js',
				'googlesitekit-module': './assets/js/googlesitekit-module.js',
				// Needed to test if a browser extension blocks this by naming convention.
				ads: './assets/js/ads.js',
			},
			externals,
			output: {
				filename: '[name].js',
				path: __dirname + '/dist/assets/js',
				chunkFilename: '[name]-[chunkhash].js',
				publicPath: '',
			},
			performance: {
				maxEntrypointSize: 175000,
			},
			module: {
				rules,
			},
			plugins: [
				new ProvidePlugin( {
					React: 'react',
				} ),
				new WebpackBar( {
					name: 'Module Entry Points',
					color: '#fbbc05',
				} ),
				new CleanWebpackPlugin( {
					// Prevent this build from removing files created by one of the other builds
					// (eg. Plugin CSS and Test files).
					cleanOnceBeforeBuildPatterns: [],
				} ),
			],
			optimization: {
				minimizer: [
					new TerserPlugin( {
						parallel: true,
						sourceMap: false,
						cache: true,
						terserOptions: {
							// We preserve function names that start with capital letters as
							// they're _likely_ component names, and these are useful to have
							// in tracebacks and error messages.
							keep_fnames: /__|_x|_n|_nx|sprintf|^[A-Z].+$/,
							output: {
								comments: /translators:/i,
							},
						},
						extractComments: false,
					} ),
				],
			},
			resolve,
		},

		// Build the main plugin admin css.
		{
			entry: {
				admin: './assets/sass/admin.scss',
				adminbar: './assets/sass/adminbar.scss',
				wpdashboard: './assets/sass/wpdashboard.scss',
			},
			module: {
				rules: [
					{
						test: /\.scss$/,
						use: [
							MiniCssExtractPlugin.loader,
							{
								loader: 'css-loader',
								options: {
									minimize: ( 'production' === mode ),
								},
							},
							'postcss-loader',
							{
								loader: 'sass-loader',
								options: {
									includePaths: [ 'node_modules' ],
								},
							},
						],
					},
					{
						test: /\.(png|woff|woff2|eot|ttf|svg|gif)$/,
						use: { loader: 'url-loader?limit=100000' },
					},
				],
			},
			plugins: [
				new MiniCssExtractPlugin( {
					filename: '/assets/css/[name].css',
				} ),
				new WebpackBar( {
					name: 'Plugin CSS',
					color: '#4285f4',
				} ),
				new CleanWebpackPlugin( {
					// Prevent this build from removing files created by one of the other builds
					// (eg. Module Entry Points and Test files).
					cleanOnceBeforeBuildPatterns: [],
				} ),
			],
		},
	];
};

const testBundle = () => {
	return {
		entry: {
			'googlesitekit-tests': './assets/js/googlesitekit-tests.js',
			'e2e-utilities': './tests/e2e/e2e-utilities.js',
		},
		output: {
			filename: '[name].js',
			path: __dirname + '/dist/assets/js',
			chunkFilename: '[name].js',
			publicPath: '',
		},
		module: {
			rules,
		},
		plugins: [
			new WebpackBar( {
				name: 'Test files',
				color: '#34a853',
			} ),
			new CleanWebpackPlugin( {
				// Prevent this build from removing files created by one of the other builds
				// (eg. Module Entry Points and Plugin CSS).
				cleanOnceBeforeBuildPatterns: [],
			} ),
		],
		externals,
		resolve,
	};
};

module.exports = ( ...args ) => {
	const { includeTests, mode } = args[ 1 ];
	const config = webpackConfig( mode );

	if ( mode !== 'production' || includeTests ) {
		// Build the test files if we aren't doing a production build.
		config.push( testBundle() );
	}

	return config;
};
<|endoftext|>


<commit_before>/* eslint-env es6 */
"use strict";

const webpack = require('webpack');
const path = require('path');
const pkg = require('./package.json');
const fs = require('fs');
const execSync = require('child_process').execSync;

module.exports = (env = {}) => {
    const minimize = env.MINIMIZE || false;
    const alpha = env.ALPHA || false;
    const maxSize = minimize ? 100 * 1024 : 512 * 1024;
    const isDevServer = process.env.WEBPACK_DEV_SERVER;

    const commitHash = execSync('git rev-parse --short HEAD').toString().trim();
    const version = !alpha ? pkg.version : `${pkg.version}-alpha+${commitHash}`;
    const license = fs.readFileSync('LICENSE', 'utf8');
    const date = new Date().toISOString().slice(0, 10);
    const name = 'matter';
    const alphaInfo = 'Experimental pre-release build.\n  ';
    const banner =
`${pkg.name} ${version} by @liabru ${date}
${alpha ? alphaInfo : ''}${pkg.homepage}
License ${pkg.license}${!minimize ? '\n\n' + license : ''}`;

    const entry = isDevServer ? './demo/js/Server.js' : './src/module/main.js';

    const externals = isDevServer ? undefined : {
        'poly-decomp': {
            commonjs: 'poly-decomp',
            commonjs2: 'poly-decomp',
            amd: 'poly-decomp',
            root: 'decomp'
        }
    };

    return {
        entry: { [name]: entry },
        output: {
            library: 'Matter',
            libraryTarget: 'umd',
            umdNamedDefine: true,
            globalObject: 'this',
            path: path.resolve(__dirname, './build'),
            filename: `[name]${alpha ? '.alpha' : ''}${minimize ? '.min' : ''}.js`
        },
        node: false,
        optimization: { minimize },
        performance: {
            maxEntrypointSize: maxSize,
            maxAssetSize: maxSize
        },
        plugins: [
            new webpack.BannerPlugin(banner),
            new webpack.DefinePlugin({
                __MATTER_VERSION__: JSON.stringify(!isDevServer ? version : '*'),
            })
        ],
        externals,
        devServer: {
            contentBase: [
                path.resolve(__dirname, './demo'),
                path.resolve(__dirname, './examples'),
                path.resolve(__dirname, './node_modules/matter-tools/build'),
                path.resolve(__dirname, './node_modules/pathseg')
            ],
            open: true,
            openPage: '',
            compress: true,
            port: 8000,
            proxy: {
                '/build': {
                    target: 'http://localhost:8000/',
                    pathRewrite: { '^/build' : '/' }
                },
                '/examples': {
                    target: 'http://localhost:8000/',
                    pathRewrite: { '^/examples' : '/' }
                },
                '/lib/matter-tools.demo.js': {
                    target: 'http://localhost:8000/',
                    pathRewrite: { '^/lib/matter-tools.demo.js' : '/matter-tools.demo.js' }
                },
                '/lib/matter-tools.inspector.js': {
                    target: 'http://localhost:8000/',
                    pathRewrite: { '^/lib/matter-tools.inspector.js' : '/matter-tools.inspector.js' }
                },
                '/lib/matter-tools.gui.js': {
                    target: 'http://localhost:8000/',
                    pathRewrite: { '^/lib/matter-tools.gui.js' : '/matter-tools.gui.js' }
                },
                '/lib/pathseg.js': {
                    target: 'http://localhost:8000/',
                    pathRewrite: { '^/lib/pathseg.js' : '/pathseg.js' }
                }
            }
        }
    };
};
<commit_msg>enable useful dev server features<commit_after>/* eslint-env es6 */
"use strict";

const webpack = require('webpack');
const path = require('path');
const pkg = require('./package.json');
const fs = require('fs');
const execSync = require('child_process').execSync;

module.exports = (env = {}) => {
    const minimize = env.MINIMIZE || false;
    const alpha = env.ALPHA || false;
    const maxSize = minimize ? 100 * 1024 : 512 * 1024;
    const isDevServer = process.env.WEBPACK_DEV_SERVER;

    const commitHash = execSync('git rev-parse --short HEAD').toString().trim();
    const version = !alpha ? pkg.version : `${pkg.version}-alpha+${commitHash}`;
    const license = fs.readFileSync('LICENSE', 'utf8');
    const date = new Date().toISOString().slice(0, 10);
    const name = 'matter';
    const alphaInfo = 'Experimental pre-release build.\n  ';
    const banner =
`${pkg.name} ${version} by @liabru ${date}
${alpha ? alphaInfo : ''}${pkg.homepage}
License ${pkg.license}${!minimize ? '\n\n' + license : ''}`;

    const entry = isDevServer ? './demo/js/Server.js' : './src/module/main.js';

    const externals = isDevServer ? undefined : {
        'poly-decomp': {
            commonjs: 'poly-decomp',
            commonjs2: 'poly-decomp',
            amd: 'poly-decomp',
            root: 'decomp'
        }
    };

    return {
        entry: { [name]: entry },
        output: {
            library: 'Matter',
            libraryTarget: 'umd',
            umdNamedDefine: true,
            globalObject: 'this',
            path: path.resolve(__dirname, './build'),
            filename: `[name]${alpha ? '.alpha' : ''}${minimize ? '.min' : ''}.js`
        },
        node: false,
        optimization: { minimize },
        performance: {
            maxEntrypointSize: maxSize,
            maxAssetSize: maxSize
        },
        plugins: [
            new webpack.BannerPlugin(banner),
            new webpack.DefinePlugin({
                __MATTER_VERSION__: JSON.stringify(!isDevServer ? version : '*'),
            })
        ],
        externals,
        devServer: {
            contentBase: [
                path.resolve(__dirname, './demo'),
                path.resolve(__dirname, './examples'),
                path.resolve(__dirname, './node_modules/matter-tools/build'),
                path.resolve(__dirname, './node_modules/pathseg')
            ],
            watchContentBase: true,
            open: true,
            openPage: '',
            compress: true,
            overlay: true,
            port: 8000,
            proxy: {
                '/build': {
                    target: 'http://localhost:8000/',
                    pathRewrite: { '^/build' : '/' }
                },
                '/examples': {
                    target: 'http://localhost:8000/',
                    pathRewrite: { '^/examples' : '/' }
                },
                '/lib/matter-tools.demo.js': {
                    target: 'http://localhost:8000/',
                    pathRewrite: { '^/lib/matter-tools.demo.js' : '/matter-tools.demo.js' }
                },
                '/lib/matter-tools.inspector.js': {
                    target: 'http://localhost:8000/',
                    pathRewrite: { '^/lib/matter-tools.inspector.js' : '/matter-tools.inspector.js' }
                },
                '/lib/matter-tools.gui.js': {
                    target: 'http://localhost:8000/',
                    pathRewrite: { '^/lib/matter-tools.gui.js' : '/matter-tools.gui.js' }
                },
                '/lib/pathseg.js': {
                    target: 'http://localhost:8000/',
                    pathRewrite: { '^/lib/pathseg.js' : '/pathseg.js' }
                }
            }
        }
    };
};
<|endoftext|>


<commit_before>module.exports = {
  entry: './client/main.js',
  output: {
    path: __dirname + '/client/build',
    filename: 'bundle.js',
  },
  module: {
    loaders: [
      {
        test: /\.jsx?$/,
        exclude: /node_modules/,
        loader: 'babel',
        query: {
          presets: ['react']
        }
      },
      {
        test: /\.css$/,
        loader: 'style!css'
      }
    ]
  }
};
<commit_msg>[feature] add minification<commit_after>var webpack = require('webpack');

module.exports = {
  entry: './client/main.js',
  output: {
    path: __dirname + '/client/build',
    filename: 'bundle.js',
  },
  plugins: [
    new webpack.optimize.UglifyJsPlugin({
      sourceMap: false,
      mangle: true,
      compress: {
        warnings: false
      },
      minimize: true
    }),
  ],
  module: {
    loaders: [
      {
        test: /\.jsx?$/,
        exclude: /node_modules/,
        loader: 'babel',
        query: {
          presets: ['react']
        }
      },
      {
        test: /\.css$/,
        loader: 'style!css'
      }
    ]
  }
};
<|endoftext|>


<commit_before>var path = require('path');
var webpack = require('webpack');

module.exports = {
  entry: path.resolve(__dirname, 'index.js'),
  externals: {
    clappr: 'Clappr'
  },
  module: {
    loaders: [
      {
        test: /\.js$/,
        loader: 'babel',
        query: {
            compact: true,
        }
      }
    ],
  },
  resolve: {
    extensions: ['', '.js'],
  },
  output: {
    filename: 'streamroot-playback.js',
    library: 'StreamrootPlayback',
    libraryTarget: 'umd',
  },
};
<commit_msg>update webpack<commit_after>var path = require('path');
var webpack = require('webpack');

module.exports = {
  entry: path.resolve(__dirname, 'index.js'),
  externals: {
    clappr: 'Clappr'
  },
  module: {
    loaders: [
      {
        test: /\.js$/,
        loader: 'babel',
        query: {
            compact: true,
        }
      }
    ],
  },
  resolve: {
    extensions: ['', '.js'],
  },
  output: {
    filename: 'public/streamroot-playback.js',
    library: 'StreamrootPlayback',
    libraryTarget: 'umd',
  },
};
<|endoftext|>


<commit_before>const webpack = require('webpack');
const path = require('path');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const ScriptExtHtmlWebpackPlugin = require('script-ext-html-webpack-plugin');
const UglifyJSPlugin = require('uglifyjs-webpack-plugin');
const SWPrecacheWebpackPlugin = require('sw-precache-webpack-plugin');
const AddAssetHtmlPlugin = require('add-asset-html-webpack-plugin');

const sassThreadLoader = require('thread-loader');

sassThreadLoader.warmup({ workerParallelJobs: 2 }, [
  'sass-loader',
  'postcss-loader',
  'css-loader',
  'style-loader',
  'babel-loader',
]);

// replace localhost with 0.0.0.0 if you want to access
// your app from wifi or a virtual machine
const host = process.env.HOST || 'localhost';
const port = process.env.PORT || 3000;
const sourcePath = path.join(__dirname, './app');
const buildDirectory = path.join(__dirname, './build');

const stats = {
  assets: true,
  children: false,
  chunks: false,
  hash: false,
  modules: false,
  publicPath: false,
  timings: true,
  version: false,
  warnings: true,
  colors: {
    green: '\u001b[32m',
  },
};

module.exports = function(env) {
  const nodeEnv = env && env.prod ? 'production' : 'development';
  const isProd = nodeEnv === 'production';

  const serviceWorkerBuild = env && env.sw;

  const htmlTemplate = isProd ? 'index.prod.ejs' : 'index.dev.ejs';

  let cssLoader;

  const plugins = [
    new webpack.optimize.CommonsChunkPlugin({
      async: true,
      children: true,
      minChunks: 2,
    }),

    // setting production environment will strip out
    // some of the development code from the app
    // and libraries
    new webpack.DefinePlugin({
      'process.env': { NODE_ENV: JSON.stringify(nodeEnv) },
    }),

    // create index.html
    new HtmlWebpackPlugin({
      template: htmlTemplate,
      inject: true,
      production: isProd,
      preload: ['*.css'],
      minify: isProd && {
        removeComments: true,
        collapseWhitespace: true,
        removeRedundantAttributes: true,
        useShortDoctype: true,
        removeEmptyAttributes: true,
        removeStyleLinkTypeAttributes: true,
        keepClosingSlash: true,
        minifyJS: true,
        minifyCSS: true,
        minifyURLs: true,
      },
    }),

    // make sure script tags are async to avoid blocking html render
    new ScriptExtHtmlWebpackPlugin({
      defaultAttribute: 'async',
      preload: {
        test: /^0|^main|^style-.*$/,
        chunks: 'all',
      },
    }),
  ];

  if (isProd) {
    plugins.push(
      // create css bundle
      new ExtractTextPlugin('style-[contenthash:8].css'),
      // minify remove some of the dead code
      new UglifyJSPlugin({
        compress: {
          warnings: false,
          screw_ie8: true,
          conditionals: true,
          unused: true,
          comparisons: true,
          sequences: true,
          dead_code: true,
          evaluate: true,
          if_return: true,
          join_vars: true,
        },
      })
    );

    cssLoader = ExtractTextPlugin.extract({
      fallback: 'style-loader',
      use: [
        'cache-loader',
        {
          loader: 'thread-loader',
          options: {
            workerParallelJobs: 2,
          },
        },
        {
          loader: 'css-loader',
          options: {
            module: true, // css-loader 0.14.5 compatible
            modules: true,
            importLoaders: 1,
            localIdentName: '[hash:base64:5]',
          },
        },
        {
          loader: 'postcss-loader',
          options: {
            sourceMap: true,
          },
        },
        {
          loader: 'sass-loader',
          options: {
            outputStyle: 'collapsed',
            sourceMap: true,
            includePaths: [sourcePath],
          },
        },
      ],
    });
  } else {
    plugins.push(
      // make hot reloading work
      new webpack.HotModuleReplacementPlugin(),
      // show module names instead of numbers in webpack stats
      new webpack.NamedModulesPlugin(),
      // don't spit out any errors in compiled assets
      new webpack.NoEmitOnErrorsPlugin(),
      // load DLL files
      /* eslint-disable global-require */
      new webpack.DllReferencePlugin({
        context: __dirname,
        manifest: require('./dll/libs-manifest.json'),
      }),
      /* eslint-enable global-require */

      // make DLL assets available for the app to download
      new AddAssetHtmlPlugin([{ filepath: require.resolve('./dll/libs.dll.js') }])
    );

    cssLoader = [
      // cache css output for faster rebuilds
      'cache-loader',
      {
        // build css/sass in threads (faster)
        loader: 'thread-loader',
        options: {
          workerParallelJobs: 2,
        },
      },
      {
        loader: 'style-loader',
      },
      {
        loader: 'css-loader',
        options: {
          module: true,
          importLoaders: 1,
          localIdentName: '[path][name]-[local]',
        },
      },
      {
        loader: 'postcss-loader',
        options: {
          sourceMap: true,
        },
      },
      {
        loader: 'sass-loader',
        options: {
          outputStyle: 'expanded',
          sourceMap: false,
          includePaths: [sourcePath],
        },
      },
    ];
  }

  if (serviceWorkerBuild) {
    plugins.push(
      new SWPrecacheWebpackPlugin({
        cacheId: 'budgeting-app',
        filename: 'sw.js',
        maximumFileSizeToCacheInBytes: 800000,
        mergeStaticsConfig: true,
        minify: true,
        runtimeCaching: [
          {
            handler: 'cacheFirst',
            urlPattern: /(.*?)/,
          },
        ],
      })
    );
  }

  const entryPoint = isProd
    ? './index.js'
    : [
        // activate HMR for React
        'react-hot-loader/patch',

        // bundle the client for webpack-dev-server
        // and connect to the provided endpoint
        `webpack-dev-server/client?http://${host}:${port}`,

        // bundle the client for hot reloading
        // only- means to only hot reload for successful updates
        'webpack/hot/only-dev-server',

        // the entry point of our app
        './index.js',
      ];

  return {
    devtool: isProd ? 'cheap-source-map' : 'eval-cheap-module-source-map',
    context: sourcePath,
    entry: {
      main: entryPoint,
    },
    output: {
      path: buildDirectory,
      publicPath: '/',
      // Computing hashes is expensive and we don't need them in development
      filename: isProd ? '[name]-[hash:8].js' : '[name].js',
      chunkFilename: isProd ? '[name]-[chunkhash:8].js' : '[name].js',
    },
    module: {
      rules: [
        {
          test: /\.(html|svg|jpe?g|png|ttf|woff2?)$/,
          include: sourcePath,
          use: {
            loader: 'file-loader',
            options: {
              name: isProd ? 'static/[name]-[hash:8].[ext]' : 'static/[name].[ext]',
            },
          },
        },
        {
          test: /\.scss$/,
          include: sourcePath,
          use: cssLoader,
        },
        {
          test: /\.(js|jsx)$/,
          include: sourcePath,
          use: [
            {
              loader: 'thread-loader',
              options: {
                workerParallelJobs: 2,
              },
            },
            'babel-loader',
          ],
        },
      ],
    },
    resolve: {
      extensions: ['.webpack-loader.js', '.web-loader.js', '.loader.js', '.js', '.scss'],
      modules: [path.resolve(__dirname, 'node_modules'), sourcePath],
      symlinks: false,
    },

    plugins,

    performance: isProd && {
      maxAssetSize: 300000,
      maxEntrypointSize: 300000,
      hints: 'warning',
    },

    stats: stats,

    devServer: {
      contentBase: './app',
      publicPath: '/',
      historyApiFallback: true,
      port: port,
      host: host,
      hot: !isProd,
      compress: isProd,
      stats: stats,
    },
  };
};
<commit_msg>Make libs.dll.js load synchronously (#105)<commit_after>const webpack = require('webpack');
const path = require('path');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const ScriptExtHtmlWebpackPlugin = require('script-ext-html-webpack-plugin');
const UglifyJSPlugin = require('uglifyjs-webpack-plugin');
const SWPrecacheWebpackPlugin = require('sw-precache-webpack-plugin');
const AddAssetHtmlPlugin = require('add-asset-html-webpack-plugin');

const sassThreadLoader = require('thread-loader');

sassThreadLoader.warmup({ workerParallelJobs: 2 }, [
  'sass-loader',
  'postcss-loader',
  'css-loader',
  'style-loader',
  'babel-loader',
]);

// replace localhost with 0.0.0.0 if you want to access
// your app from wifi or a virtual machine
const host = process.env.HOST || 'localhost';
const port = process.env.PORT || 3000;
const sourcePath = path.join(__dirname, './app');
const buildDirectory = path.join(__dirname, './build');

const stats = {
  assets: true,
  children: false,
  chunks: false,
  hash: false,
  modules: false,
  publicPath: false,
  timings: true,
  version: false,
  warnings: true,
  colors: {
    green: '\u001b[32m',
  },
};

module.exports = function(env) {
  const nodeEnv = env && env.prod ? 'production' : 'development';
  const isProd = nodeEnv === 'production';

  const serviceWorkerBuild = env && env.sw;

  const htmlTemplate = isProd ? 'index.prod.ejs' : 'index.dev.ejs';

  let cssLoader;

  const plugins = [
    new webpack.optimize.CommonsChunkPlugin({
      async: true,
      children: true,
      minChunks: 2,
    }),

    // setting production environment will strip out
    // some of the development code from the app
    // and libraries
    new webpack.DefinePlugin({
      'process.env': { NODE_ENV: JSON.stringify(nodeEnv) },
    }),

    // create index.html
    new HtmlWebpackPlugin({
      template: htmlTemplate,
      inject: true,
      production: isProd,
      preload: ['*.css'],
      minify: isProd && {
        removeComments: true,
        collapseWhitespace: true,
        removeRedundantAttributes: true,
        useShortDoctype: true,
        removeEmptyAttributes: true,
        removeStyleLinkTypeAttributes: true,
        keepClosingSlash: true,
        minifyJS: true,
        minifyCSS: true,
        minifyURLs: true,
      },
    }),

    // make sure script tags are async to avoid blocking html render
    new ScriptExtHtmlWebpackPlugin({
      defaultAttribute: 'async',
      sync: /^libs.dll.*$/,
      preload: {
        test: /^0|^main|^style-.*$/,
        chunks: 'all',
      },
    }),
  ];

  if (isProd) {
    plugins.push(
      // create css bundle
      new ExtractTextPlugin('style-[contenthash:8].css'),
      // minify remove some of the dead code
      new UglifyJSPlugin({
        compress: {
          warnings: false,
          screw_ie8: true,
          conditionals: true,
          unused: true,
          comparisons: true,
          sequences: true,
          dead_code: true,
          evaluate: true,
          if_return: true,
          join_vars: true,
        },
      })
    );

    cssLoader = ExtractTextPlugin.extract({
      fallback: 'style-loader',
      use: [
        'cache-loader',
        {
          loader: 'thread-loader',
          options: {
            workerParallelJobs: 2,
          },
        },
        {
          loader: 'css-loader',
          options: {
            module: true, // css-loader 0.14.5 compatible
            modules: true,
            importLoaders: 1,
            localIdentName: '[hash:base64:5]',
          },
        },
        {
          loader: 'postcss-loader',
          options: {
            sourceMap: true,
          },
        },
        {
          loader: 'sass-loader',
          options: {
            outputStyle: 'collapsed',
            sourceMap: true,
            includePaths: [sourcePath],
          },
        },
      ],
    });
  } else {
    plugins.push(
      // make hot reloading work
      new webpack.HotModuleReplacementPlugin(),
      // show module names instead of numbers in webpack stats
      new webpack.NamedModulesPlugin(),
      // don't spit out any errors in compiled assets
      new webpack.NoEmitOnErrorsPlugin(),
      // load DLL files
      /* eslint-disable global-require */
      new webpack.DllReferencePlugin({
        context: __dirname,
        manifest: require('./dll/libs-manifest.json'),
      }),
      /* eslint-enable global-require */

      // make DLL assets available for the app to download
      new AddAssetHtmlPlugin([{ filepath: require.resolve('./dll/libs.dll.js') }])
    );

    cssLoader = [
      // cache css output for faster rebuilds
      'cache-loader',
      {
        // build css/sass in threads (faster)
        loader: 'thread-loader',
        options: {
          workerParallelJobs: 2,
        },
      },
      {
        loader: 'style-loader',
      },
      {
        loader: 'css-loader',
        options: {
          module: true,
          importLoaders: 1,
          localIdentName: '[path][name]-[local]',
        },
      },
      {
        loader: 'postcss-loader',
        options: {
          sourceMap: true,
        },
      },
      {
        loader: 'sass-loader',
        options: {
          outputStyle: 'expanded',
          sourceMap: false,
          includePaths: [sourcePath],
        },
      },
    ];
  }

  if (serviceWorkerBuild) {
    plugins.push(
      new SWPrecacheWebpackPlugin({
        cacheId: 'budgeting-app',
        filename: 'sw.js',
        maximumFileSizeToCacheInBytes: 800000,
        mergeStaticsConfig: true,
        minify: true,
        runtimeCaching: [
          {
            handler: 'cacheFirst',
            urlPattern: /(.*?)/,
          },
        ],
      })
    );
  }

  const entryPoint = isProd
    ? './index.js'
    : [
        // activate HMR for React
        'react-hot-loader/patch',

        // bundle the client for webpack-dev-server
        // and connect to the provided endpoint
        `webpack-dev-server/client?http://${host}:${port}`,

        // bundle the client for hot reloading
        // only- means to only hot reload for successful updates
        'webpack/hot/only-dev-server',

        // the entry point of our app
        './index.js',
      ];

  return {
    devtool: isProd ? 'cheap-source-map' : 'eval-cheap-module-source-map',
    context: sourcePath,
    entry: {
      main: entryPoint,
    },
    output: {
      path: buildDirectory,
      publicPath: '/',
      // Computing hashes is expensive and we don't need them in development
      filename: isProd ? '[name]-[hash:8].js' : '[name].js',
      chunkFilename: isProd ? '[name]-[chunkhash:8].js' : '[name].js',
    },
    module: {
      rules: [
        {
          test: /\.(html|svg|jpe?g|png|ttf|woff2?)$/,
          include: sourcePath,
          use: {
            loader: 'file-loader',
            options: {
              name: isProd ? 'static/[name]-[hash:8].[ext]' : 'static/[name].[ext]',
            },
          },
        },
        {
          test: /\.scss$/,
          include: sourcePath,
          use: cssLoader,
        },
        {
          test: /\.(js|jsx)$/,
          include: sourcePath,
          use: [
            {
              loader: 'thread-loader',
              options: {
                workerParallelJobs: 2,
              },
            },
            'babel-loader',
          ],
        },
      ],
    },
    resolve: {
      extensions: ['.webpack-loader.js', '.web-loader.js', '.loader.js', '.js', '.scss'],
      modules: [path.resolve(__dirname, 'node_modules'), sourcePath],
      symlinks: false,
    },

    plugins,

    performance: isProd && {
      maxAssetSize: 300000,
      maxEntrypointSize: 300000,
      hints: 'warning',
    },

    stats: stats,

    devServer: {
      contentBase: './app',
      publicPath: '/',
      historyApiFallback: true,
      port: port,
      host: host,
      hot: !isProd,
      compress: isProd,
      stats: stats,
    },
  };
};
<|endoftext|>


<commit_before>const path = require('path');
const webpack = require('webpack');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const InlineManifestWebpackPlugin = require('inline-manifest-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const ScriptExtHtmlWebpackPlugin = require('script-ext-html-webpack-plugin');

const projectConfig = require('./config.js');

const isProd = process.env.NODE_ENV === 'production';

const cssLoaderConfig = {
  modules: true,
  importLoaders: 1,
  localIdentName: '[name]__[local]___[hash:base64:5]',
};

const prodCssConfig = ExtractTextPlugin.extract({
  fallbackLoader: 'style-loader',
  loader: [
    {
      loader: 'css-loader',
      query: cssLoaderConfig,
    },
    { loader: 'postcss-loader' },
  ],
  publicPath: '/',
});

const devCssConfig = [
  { loader: 'style-loader' },
  {
    loader: 'css-loader',
    options: Object.assign(
      {},
      { sourceMap: true },
      // This doesn't go through Babel so no ES2017 stuff
      cssLoaderConfig // eslint-disable-line comma-dangle
    ),
  },
  { loader: 'postcss-loader' },
];

const wpconfig = {
  entry: {
    main: './src/index.js',
  },
  output: {
    path: `${__dirname}/dist`,
    filename: isProd ? '[name].[chunkhash].js' : '[name].js',
    publicPath: isProd ? '/' : 'http://localhost:8080',
  },
  devtool: 'source-map',
  module: {
    rules: [
      {
        test: /\.woff(2)?(\?[a-z0-9=]+)?$/,
        use: [
          {
            loader: 'url-loader',
            options: {
              limit: 64000,
            },
          },
        ],
      },
      {
        test: /\.(png|jpe?g|gif|svg)(\?[a-z0-9=]+)?$/,
        use: 'file-loader',
      },
      {
        test: /\.js$/,
        include: path.join(__dirname, 'src'),
        use: 'babel-loader',
      },
      {
        test: /\.css$/,
        loader: isProd ? prodCssConfig : devCssConfig,
      },
    ],
  },
  resolve: {
    extensions: ['.js', '.json', '.css'],
  },
  plugins: [
    new webpack.NoEmitOnErrorsPlugin(),
    new webpack.NamedModulesPlugin(),
    new webpack.DefinePlugin({
      'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV || 'development'),
      'process.env.TRAVIS_COMMIT': JSON.stringify(process.env.TRAVIS_COMMIT || 'unreleased'),
    }),
    new webpack.optimize.CommonsChunkPlugin({
      name: 'vendor',
      minChunks: ({ resource }) => /node_modules/.test(resource),
    }),
    new webpack.optimize.CommonsChunkPlugin('manifest'),
    new InlineManifestWebpackPlugin(),
    new HtmlWebpackPlugin({
      title: projectConfig.ProjectName,
      template: './src/index.html',
      favicon: './src/assets/images/favicon.ico',
    }),
    new ScriptExtHtmlWebpackPlugin({
      defaultAttribute: 'defer',
    }),
  ],
  devServer: {
    hot: true,
    publicPath: '/',
    historyApiFallback: true,
    overlay: true,
  },
  performance: {
    maxAssetSize: 350000,
    maxEntrypointSize: 500000,
    hints: isProd ? 'warning' : false,
  },
};

if (!isProd) {
  wpconfig.plugins = [new webpack.HotModuleReplacementPlugin(), ...wpconfig.plugins];
} else {
  wpconfig.plugins = [
    new ExtractTextPlugin({
      filename: isProd ? '[name].[contenthash].css' : '[name].css',
    }),
    new webpack.optimize.UglifyJsPlugin({ sourceMap: true }),
    ...wpconfig.plugins,
  ];
}

module.exports = wpconfig;
<commit_msg>[bugfix] publicPath trailing slash<commit_after>const path = require('path');
const webpack = require('webpack');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const InlineManifestWebpackPlugin = require('inline-manifest-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const ScriptExtHtmlWebpackPlugin = require('script-ext-html-webpack-plugin');

const projectConfig = require('./config.js');

const isProd = process.env.NODE_ENV === 'production';

const cssLoaderConfig = {
  modules: true,
  importLoaders: 1,
  localIdentName: '[name]__[local]___[hash:base64:5]',
};

const prodCssConfig = ExtractTextPlugin.extract({
  fallbackLoader: 'style-loader',
  loader: [
    {
      loader: 'css-loader',
      query: cssLoaderConfig,
    },
    { loader: 'postcss-loader' },
  ],
  publicPath: '/',
});

const devCssConfig = [
  { loader: 'style-loader' },
  {
    loader: 'css-loader',
    options: Object.assign(
      {},
      { sourceMap: true },
      // This doesn't go through Babel so no ES2017 stuff
      cssLoaderConfig // eslint-disable-line comma-dangle
    ),
  },
  { loader: 'postcss-loader' },
];

const wpconfig = {
  entry: {
    main: './src/index.js',
  },
  output: {
    path: `${__dirname}/dist`,
    filename: isProd ? '[name].[chunkhash].js' : '[name].js',
    publicPath: isProd ? '/' : 'http://localhost:8080/',
  },
  devtool: 'source-map',
  module: {
    rules: [
      {
        test: /\.woff(2)?(\?[a-z0-9=]+)?$/,
        use: [
          {
            loader: 'url-loader',
            options: {
              limit: 64000,
            },
          },
        ],
      },
      {
        test: /\.(png|jpe?g|gif|svg)(\?[a-z0-9=]+)?$/,
        use: 'file-loader',
      },
      {
        test: /\.js$/,
        include: path.join(__dirname, 'src'),
        use: 'babel-loader',
      },
      {
        test: /\.css$/,
        loader: isProd ? prodCssConfig : devCssConfig,
      },
    ],
  },
  resolve: {
    extensions: ['.js', '.json', '.css'],
  },
  plugins: [
    new webpack.NoEmitOnErrorsPlugin(),
    new webpack.NamedModulesPlugin(),
    new webpack.DefinePlugin({
      'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV || 'development'),
      'process.env.TRAVIS_COMMIT': JSON.stringify(process.env.TRAVIS_COMMIT || 'unreleased'),
    }),
    new webpack.optimize.CommonsChunkPlugin({
      name: 'vendor',
      minChunks: ({ resource }) => /node_modules/.test(resource),
    }),
    new webpack.optimize.CommonsChunkPlugin('manifest'),
    new InlineManifestWebpackPlugin(),
    new HtmlWebpackPlugin({
      title: projectConfig.ProjectName,
      template: './src/index.html',
      favicon: './src/assets/images/favicon.ico',
    }),
    new ScriptExtHtmlWebpackPlugin({
      defaultAttribute: 'defer',
    }),
  ],
  devServer: {
    hot: true,
    publicPath: '/',
    historyApiFallback: true,
    overlay: true,
  },
  performance: {
    maxAssetSize: 350000,
    maxEntrypointSize: 500000,
    hints: isProd ? 'warning' : false,
  },
};

if (!isProd) {
  wpconfig.plugins = [new webpack.HotModuleReplacementPlugin(), ...wpconfig.plugins];
} else {
  wpconfig.plugins = [
    new ExtractTextPlugin({
      filename: isProd ? '[name].[contenthash].css' : '[name].css',
    }),
    new webpack.optimize.UglifyJsPlugin({ sourceMap: true }),
    ...wpconfig.plugins,
  ];
}

module.exports = wpconfig;
<|endoftext|>


<commit_before>/* eslint-disable */
const CopyWebpackPlugin = require('copy-webpack-plugin');
const webpack = require('webpack');
const path = require('path');

var apiHost;

var setupAPI=function() {
  switch(process.env.NODE_ENV) {
    case 'production':
      apiHost = "'https://wetracker-be.herokuapp.com/'";
      break;
    case 'dev':
    default:
      apiHost = "'http://localhost:8080/'";
      break;
  }
};

setupAPI();

module.exports = [
	{
		entry: [
			'./src/app.js',
		],
		output: {
			path: path.join(__dirname, '/bin/'),
			filename: 'app.bundle.js',
			publicPath: '/bin/',
		},
		devServer: {
			inline: true,
			port: 8082,
			hot: true,
		},
		module: {
			rules: [{
				test: /\.js$/,
				exclude: /node_modules/,
				loader: 'babel-loader',
				query: {
					presets: ['@babel/env'],
					plugins: [
						"@babel/transform-exponentiation-operator"
					]
				}
			}, {
				test: /\.css$/,
				loader: 'style-loader!css-loader',
			}, {
        test: /\.(scss)$/,
        use: [
          {
            loader: 'css-loader',
          }, {
            loader: 'sass-loader',
          }
        ]
      }, {
				test: /\.dot$/,
				loader: 'raw-loader',
			},{
				test: /\.woff(2)?(\?v=[0-9]\.[0-9]\.[0-9])?$/,
				loader: "url-loader?limit=10000&mimetype=application/font-woff"
			}, {
				test: /\.(ttf|eot|svg)(\?v=[0-9]\.[0-9]\.[0-9])?$/,
				loader: "file-loader"
			}, {
				test: /\.(jpg|png|gif)$/,
				loader: "file-loader"
			}, {
				test: /\.xm$/,
				loader: "file-loader"
			}, {
				test: /\.marko$/,
				loader: "marko-loader"
			}, {
				test: /\.lz4$/,
				loader: "arraybuffer-loader"
			}]
		},
		node: {
			fs: "empty",
		},
		plugins: [
			new CopyWebpackPlugin([
				{from: 'index.html'},
			]),
			new webpack.HotModuleReplacementPlugin(),
			new webpack.DefinePlugin({
				__API__: apiHost,
			}),
			new webpack.ProvidePlugin({
				$: "jquery",
				jQuery: "jquery"
			}),
		],
		// Emit a source map for easier debugging
		devtool: 'source-map',
		resolve: {
			alias: {
					'jquery-ui': 'jquery-ui/ui'
			}
		},
		resolveLoader: {
			alias: {
				'copy': 'file-loader?name=[path][name].[ext]&context=./src',
			}
		}
	}
]
/* eslint-enable */
<commit_msg>Add mode flag to webpack config<commit_after>/* eslint-disable */
const CopyWebpackPlugin = require('copy-webpack-plugin');
const webpack = require('webpack');
const path = require('path');

var apiHost;

var setupAPI=function() {
  switch(process.env.NODE_ENV) {
    case 'production':
      apiHost = "'https://wetracker-be.herokuapp.com/'";
      break;
    case 'dev':
    default:
      apiHost = "'http://localhost:8080/'";
      break;
  }
};

setupAPI();

module.exports = [
	{
		mode: 'development',
		entry: [
			'./src/app.js',
		],
		output: {
			path: path.join(__dirname, '/bin/'),
			filename: 'app.bundle.js',
			publicPath: '/bin/',
		},
		devServer: {
			inline: true,
			port: 8082,
			hot: true,
		},
		module: {
			rules: [{
				test: /\.js$/,
				exclude: /node_modules/,
				loader: 'babel-loader',
				query: {
					presets: ['@babel/env'],
					plugins: [
						"@babel/transform-exponentiation-operator"
					]
				}
			}, {
				test: /\.css$/,
				loader: 'style-loader!css-loader',
			}, {
        test: /\.(scss)$/,
        use: [
          {
            loader: 'css-loader',
          }, {
            loader: 'sass-loader',
          }
        ]
      }, {
				test: /\.dot$/,
				loader: 'raw-loader',
			},{
				test: /\.woff(2)?(\?v=[0-9]\.[0-9]\.[0-9])?$/,
				loader: "url-loader?limit=10000&mimetype=application/font-woff"
			}, {
				test: /\.(ttf|eot|svg)(\?v=[0-9]\.[0-9]\.[0-9])?$/,
				loader: "file-loader"
			}, {
				test: /\.(jpg|png|gif)$/,
				loader: "file-loader"
			}, {
				test: /\.xm$/,
				loader: "file-loader"
			}, {
				test: /\.marko$/,
				loader: "marko-loader"
			}, {
				test: /\.lz4$/,
				loader: "arraybuffer-loader"
			}]
		},
		node: {
			fs: "empty",
		},
		plugins: [
			new CopyWebpackPlugin([
				{from: 'index.html'},
			]),
			new webpack.HotModuleReplacementPlugin(),
			new webpack.DefinePlugin({
				__API__: apiHost,
			}),
			new webpack.ProvidePlugin({
				$: "jquery",
				jQuery: "jquery"
			}),
		],
		// Emit a source map for easier debugging
		devtool: 'source-map',
		resolve: {
			alias: {
					'jquery-ui': 'jquery-ui/ui'
			}
		},
		resolveLoader: {
			alias: {
				'copy': 'file-loader?name=[path][name].[ext]&context=./src',
			}
		}
	}
]
/* eslint-enable */
<|endoftext|>


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

var moduleBundle = {

  entry: {
    'quill-cursors': ['./src/cursors.js', './src/cursors.scss'],
    'quill-cursors.min': ['./src/cursors.js'],
  },

  output: {
    filename: '[name].js',
    path: path.resolve(__dirname, 'dist')
  },

  externals: {
    quill: 'Quill'
  },

  module: {
    rules: [{
      test: /\.scss$/,
      loader: ExtractTextPlugin.extract(['css-loader', 'sass-loader'])
    }]
  },

  plugins: [
    new UglifyJSPlugin({
      include: /\.min\.js$/,
    }),
    new ExtractTextPlugin({ // define where to save the file
      filename: '[name].css'
    })
  ],

  devServer: {
    contentBase: [
      path.join(__dirname, 'example'),
      path.join(__dirname, 'dist'),
      path.join(__dirname, 'node_modules/normalize.css'),
      path.join(__dirname, 'node_modules/quill/dist')
    ]
  },
};

module.exports = [moduleBundle];
<commit_msg>Build library with UMD<commit_after>var path = require('path');
var UglifyJSPlugin = require('uglifyjs-webpack-plugin');
var ExtractTextPlugin = require('extract-text-webpack-plugin');

var moduleBundle = {

  entry: {
    'quill-cursors': ['./src/cursors.js', './src/cursors.scss'],
    'quill-cursors.min': ['./src/cursors.js'],
  },

  output: {
    filename: '[name].js',
    library: 'QuillCursors',
    libraryTarget: 'umd',
    path: path.resolve(__dirname, 'dist')
  },

  externals: {
    quill: 'Quill'
  },

  module: {
    rules: [{
      test: /\.scss$/,
      loader: ExtractTextPlugin.extract(['css-loader', 'sass-loader'])
    }]
  },

  plugins: [
    new UglifyJSPlugin({
      include: /\.min\.js$/,
    }),
    new ExtractTextPlugin({ // define where to save the file
      filename: '[name].css'
    })
  ],

  devServer: {
    contentBase: [
      path.join(__dirname, 'example'),
      path.join(__dirname, 'dist'),
      path.join(__dirname, 'node_modules/normalize.css'),
      path.join(__dirname, 'node_modules/quill/dist')
    ]
  },
};

module.exports = [moduleBundle];
<|endoftext|>


<commit_before>const path = require('path')
const MinifyPlugin = require('babel-minify-webpack-plugin')
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin

const plugins = [new MinifyPlugin()]

if (process.argv.includes('--analyze')) {
  plugins.push(new BundleAnalyzerPlugin())
}

module.exports = {
  entry: './src/index.js',
  output: {
    path: path.join(__dirname, './build/dist'),
    filename: 'datebook.js',
    library: 'datebook',
    libraryTarget: 'umd'
  },
  target: 'node',
  resolve: {
    extensions: ['.js'],
  },
  module: {
    rules: [
      {
        test: /\.js$/,
        exclude: /node_modules/,
        use: {
          loader: 'babel-loader'
        }
      }
    ]
  },
  plugins,
  mode: 'development',
  devtool: 'eval-source-map'
}<commit_msg>fix: reduces bundle size (#108)<commit_after>const path = require('path')
const MinifyPlugin = require('babel-minify-webpack-plugin')
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin

const plugins = [new MinifyPlugin()]

if (process.argv.includes('--analyze')) {
  plugins.push(new BundleAnalyzerPlugin())
}

module.exports = {
  entry: './src/index.js',
  output: {
    path: path.join(__dirname, './build/dist'),
    filename: 'datebook.js',
    library: 'datebook',
    libraryTarget: 'umd'
  },
  target: 'node',
  resolve: {
    extensions: ['.js'],
  },
  module: {
    rules: [
      {
        test: /\.js$/,
        exclude: /node_modules/,
        use: {
          loader: 'babel-loader'
        }
      }
    ]
  },
  plugins,
  mode: 'production'
}<|endoftext|>


<commit_before>/* eslint-env node */
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const webpack = require('webpack');

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

module.exports = {
    entry: [
        './src/index.jsx'
    ],
    output: {
        path: __dirname + '/public',
        publicPath: '/',
        filename: 'bundle.js'
    },
    module: {
        preLoaders: [
            {
                test: /\.jsx?$/,
                loader: 'eslint-loader',
                exclude: /node_modules/
            }
        ],
        loaders: [{
            test: /\.jsx?$/,
            exclude: /node_modules/,
            loader: 'babel-loader',
            query: {
                presets: ['es2015', 'react']
            }
        },
        {
            test: /\.scss$/,
            loader: ExtractTextPlugin.extract('css!sass')
        }]
    },
    resolve: {
        extensions: ['', '.js', '.jsx', '.scss']
    },
    plugins: [
        new webpack.DefinePlugin({
            'process.env': {
                'NODE_ENV': JSON.stringify(env)
            }
        }),
        new ExtractTextPlugin('style.css', {
            allChunks: true
        })
    ],
    devtool: 'source-map'
};
<commit_msg>generate source maps only on dev env<commit_after>/* eslint-env node */
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const webpack = require('webpack');

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

module.exports = {
    entry: [
        './src/index.jsx'
    ],
    output: {
        path: __dirname + '/public',
        publicPath: '/',
        filename: 'bundle.js'
    },
    module: {
        preLoaders: [
            {
                test: /\.jsx?$/,
                loader: 'eslint-loader',
                exclude: /node_modules/
            }
        ],
        loaders: [{
            test: /\.jsx?$/,
            exclude: /node_modules/,
            loader: 'babel-loader',
            query: {
                presets: ['es2015', 'react']
            }
        },
        {
            test: /\.scss$/,
            loader: ExtractTextPlugin.extract('css!sass')
        }]
    },
    resolve: {
        extensions: ['', '.js', '.jsx', '.scss']
    },
    plugins: [
        new webpack.DefinePlugin({
            'process.env': {
                'NODE_ENV': JSON.stringify(env)
            }
        }),
        new ExtractTextPlugin('style.css', {
            allChunks: true
        })
    ],
    devtool: env === 'development' ? 'source-map' : undefined
};
<|endoftext|>


<commit_before>/*
 * Helper: root(), and rootDir() are defined at the bottom
 */
const autoprefixer = require('autoprefixer')
const ExtractTextPlugin = require('extract-text-webpack-plugin')
const path = require('path')
/*
 * Webpack Plugins
 */
var webpack = require('webpack');
var CommonsChunkPlugin = webpack.optimize.CommonsChunkPlugin;
var ProvidePlugin = webpack.ProvidePlugin;
/*
 * SASS Config
 */
const sassLoaders = [
  'css',
  'postcss',
  'sass?indentedSyntax=sass&includePaths[]=' + path.resolve(__dirname, './assets/scss')
]
/*
 * Config
 */
const config = {
  devtool: 'source-map',
  debug: true,

  entry: {
    'angular2': [
      'rxjs',
      'reflect-metadata',
      'angular2/core',
      'angular2/router',
      'angular2/http'
    ],
    'app': [
      './app/boot',
      './assets/scss/master'
    ],
    'head': [
      './app/head'
    ]
  },

  output: {
    path: root('build'),
    publicPath: 'build/',
    filename: '[name].js',
    sourceMapFilename: '[name].js.map',
    chunkFilename: '[id].chunk.js'
  },

  resolve: {
    extensions: ['','.ts','.js','.json', '.scss', '.css', '.styl', '.html']
  },

  module: {
    preLoaders: [
      {
        test: /\.json$/,
        exclude: /node_modules/,
        loader: 'json'},
    ],
    loaders: [
      {
        test: /\.ts$/,
        loader: 'ts',
        exclude: [ /node_modules/ ]},
      {
        test: /\.js$/,
        loaders: ['babel-loader'],
        exclude: [ /node_modules/ ]},
      {
        test: /\.scss$/,
        //loader: ExtractTextPlugin.extract('style-loader', sassLoaders.join('!')),
        loaders: ['style', 'css', 'sass'],
        exclude: [ /node_modules/ ]},
      {
        test: /\.styl$/,
        loaders: ['css', 'stylus'],
        exclude: [ /node_modules/ ]
      },
      {
        test: /\.json$/,
        loader: 'json' }
    ],
    resolve: {
      modulesDirectories: ['node_modules']
    }
  },

  plugins: [
    new CommonsChunkPlugin({ name: 'angular2', filename: 'angular2.js', minChunks: Infinity }),
    new CommonsChunkPlugin({ name: 'common',   filename: 'common.js' }),
    new ExtractTextPlugin('[name].css')
  ],
  postcss: [
    autoprefixer({
      browsers: ['last 2 versions']
    })
  ],

  target: 'node-webkit'
};

/*
 * Helper functions
 */
function root(args) {
  args = Array.prototype.slice.call(arguments, 0);
  return path.join.apply(path, [__dirname].concat(args));
}

function rootNode(args) {
  args = Array.prototype.slice.call(arguments, 0);
  return root.apply(path, ['node_modules'].concat(args));
}

/*
 * Export module
 */
module.exports = config<commit_msg>Building css finished<commit_after>/*
 * Helper: root(), and rootDir() are defined at the bottom
 */
const autoprefixer = require('autoprefixer')
const ExtractTextPlugin = require('extract-text-webpack-plugin')
const path = require('path')
/*
 * Webpack Plugins
 */
var webpack = require('webpack');
var CommonsChunkPlugin = webpack.optimize.CommonsChunkPlugin;
var ProvidePlugin = webpack.ProvidePlugin;
/*
 * SASS Config
 */
const styleLoaders = [
  //'style',
  'css',
  'sass'
  //'sass?indentedSyntax=scss&includePaths[]=' + path.resolve(__dirname, './assets/scss')
]
/*
 * Config
 */
const config = {
  devtool: 'source-map',
  debug: true,

  entry: {
    'angular2': [
      'rxjs',
      'reflect-metadata',
      'angular2/core',
      'angular2/router',
      'angular2/http'
    ],
    'app': [
      './app/boot'
    ],
    'head': [
      './app/head'
    ]
  },

  output: {
    path: root('build'),
    publicPath: 'build/',
    filename: '[name].js',
    sourceMapFilename: '[name].js.map',
    chunkFilename: '[id].chunk.js'
  },

  resolve: {
    extensions: ['','.ts','.js','.json', '.scss', '.css', '.styl', '.html']
  },

  module: {
    preLoaders: [
      {
        test: /\.json$/,
        exclude: /node_modules/,
        loader: 'json'},
    ],
    loaders: [
      {
        test: /\.ts$/,
        loader: 'ts',
        exclude: [ /node_modules/ ]},
      {
        test: /\.js$/,
        loaders: ['babel-loader'],
        exclude: [ /node_modules/ ]},
      {
        test: /\.scss$/,
        loader: ExtractTextPlugin.extract('style', styleLoaders),
        //loaders: styleLoaders,
        //loaders: ['style', 'css', 'sass'],
        exclude: [ /node_modules/ ]},
      {
        test: /\.styl$/,
        loaders: ['css', 'stylus'],
        exclude: [ /node_modules/ ]
      },
      {
        test: /\.json$/,
        loader: 'json' }
    ],
    resolve: {
      modulesDirectories: ['node_modules']
    }
  },

  plugins: [
    new CommonsChunkPlugin({ name: 'angular2', filename: 'angular2.js', minChunks: Infinity }),
    new CommonsChunkPlugin({ name: 'common',   filename: 'common.js' }),
    new ExtractTextPlugin('[name].css')
  ],
  postcss: [
    autoprefixer({
      browsers: ['last 2 versions']
    })
  ],

  target: 'node-webkit'
};

/*
 * Helper functions
 */
function root(args) {
  args = Array.prototype.slice.call(arguments, 0);
  return path.join.apply(path, [__dirname].concat(args));
}

function rootNode(args) {
  args = Array.prototype.slice.call(arguments, 0);
  return root.apply(path, ['node_modules'].concat(args));
}

/*
 * Export module
 */
module.exports = config<|endoftext|>


<commit_before>module.exports = {
    context: __dirname,
    entry: './index.js',
    externals: {
        atom: 'require("atom")'
    },
    module: {
        loaders: [
            {test: /\.coffee$/, loader: 'coffee-loader'},
            {test: /\.json$/, loader: 'json-loader'},
            { test: /\.js$/, exclude: /node_modules/, loader: "babel-loader" }
        ]
    },
    output: {
        path: __dirname + '/dist',
        filename: 'bundle.js'
    },
    resolve: {
        extensions: ["", ".js", ".coffee"]
    },
    target: "atom"
}
<commit_msg>webpack<commit_after>module.exports = {
    context: __dirname,
    entry: './index.js',
    externals: {
        atom: 'require("atom")',
    },
    module: {
        loaders: [
            {test: /\.coffee$/, loader: 'coffee-loader'},
            {test: /\.json$/, loader: 'json-loader'},
            { test: /\.js$/, exclude: /node_modules/, loader: "babel-loader" },
        ]
    },
    output: {
        path: __dirname + '/dist',
        filename: 'bundle.js'
    },
    resolve: {
        extensions: ["", ".js", ".coffee"]
    },
    target: "atom"
}
<|endoftext|>