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

const loaders = require('./config/webpack/loaders')

const resolve = (_path) => {
  return path.resolve(__dirname, _path)
}

module.exports = {
  devtool: 'source-map',
  entry: resolve('src/index.js'),

  output: {
    publicPath: '/',
    path: resolve('dist/'),
    filename: 'index.js',
    libraryTarget: 'commonjs',
    umdNamedDefine: false,
  },

  externals: [/^react$/, /^react-dom$/, /^office-ui-fabric-react$/],

  resolve: {
    extensions: ['.js'],
  },

  plugins: [
    new webpack.DefinePlugin({
      __DEVELOPMENT__: false,
      __DEVTOOLS__: false,
    }),

    new webpack.DefinePlugin({
      'process.env': {
        NODE_ENV: JSON.stringify('production'),
        BABEL_ENV: JSON.stringify('production'),
      },
    }),
  ],

  module: {
    rules: [loaders.js, loaders.css, loaders.url],
  },
}
