var webpack = require('webpack');
var webpackMerge = require('webpack-merge');
var ExtractTextPlugin = require('extract-text-webpack-plugin');
var commonConfig = require('./webpack.common.js');
var helpers = require('./helpers');

const SETTINGS = {
    API_URL: 'http://localhost:52281/v1',
    API_IDENTIFIER: "138659EBEBBF408AA1282D46EBDFBDC7"
};

module.exports = webpackMerge(commonConfig, {
    devtool: 'cheap-module-eval-source-map',

    output: {
        path: helpers.root('dist'),
        publicPath: 'http://localhost:8080/',
        filename: '[name].js',
        chunkFilename: '[id].chunk.js'
    },

    plugins: [
        new webpack.optimize.OccurrenceOrderPlugin(true),
        new webpack.LoaderOptionsPlugin({
          debug: false,
          options: {
            optimization: {
              mode: 'development',
              nodeEnv: 'development',
              removeAvailableModules: true,
              removeEmptyChunks: true,
              mergeDuplicateChunks: true,
              noEmitOnErrors: true,
              runtimeChunk: 'single',
              splitChunks: {
                cacheGroups: {
                  vendor: {
                    test: /[\\/]node_modules[\\/]/,
                    name: 'vendors',
                    chunks: 'all'
                  }
                }
              }
            }
          }
        }),
        new webpack.DefinePlugin({
            SETTINGS: JSON.stringify(SETTINGS)
        }),
        new webpack.NamedModulesPlugin(),
        new webpack.NoEmitOnErrorsPlugin(),
        // new webpack.HotModuleReplacementPlugin(),
        new ExtractTextPlugin('[name].css')
    ],

    devServer: {
        historyApiFallback: true,
        stats: 'minimal',

        // contentBase: [helpers.root('dist'), helpers.root('public')],
        compress: true,
        host: 'localhost',
        port: 8080
    }
});
