const path = require('path');

const context = path.join(__dirname);
const config = {
  context,
  entry: [
    'babel-polyfill',
    './src/index.js'
  ],
  output: {
    filename: 'lib/flive-ui.js'
  },
  stats: 'minimal',
  plugins: [
  ],
  module: {
    loaders: [
      { test: require.resolve('react-addons-perf'), loader: 'expose?Perf' }
    ],
    rules: [
      {
        test: /\.js$/,
        use: [{
          loader: 'babel-loader',
          options: {
            babelrc: false,
            presets: ['es2015', 'stage-0', 'react'],
            plugins: [
              'add-module-exports',
              ['react-css-modules', {
                context,
                generateScopedName: 'flive_[name]_[local]',
                filetypes: {
                  '.scss': {
                    syntax: 'postcss-scss'
                  }
                }
              }]
            ]
          }
        }],
        exclude: /node_modules/,
        include: context
      },
      {
        test: /\.(scss)$/,
        loader: [
          {
            loader: 'style-loader'
          },
          {
            loader: 'css-loader?importLoader=1&modules&localIdentName=flive_[name]_[local]'
          },
          // { loader: 'resolve-url'},
          {
            loader: 'sass-loader',
            options: {
              includePaths: [
                './node_modules/susy/sass',
                `${context}/src/_assets/style`,
                `${context}/src/_assets/style-override`
              ]
            }
          }
        ]
      },
      {
        test: /\.(css)$/,
        loader: [
          {
            loader: 'style-loader'
          },
          {
            loader: 'css-loader'
          }
        ]
      },
      {
        test: /\.(ttf|otf|svg|eot)(\?.*)?$/,
        use: ['file-loader']
      },
      {
        test: /\.(woff|woff2)(\?.*)?$/,
        use: ['base64-font-loader']
      },
      {
        test: /\.(png|jpg|gif)$/,
        use: ['file-loader']
      }
    ]
  }
};

module.exports = config;
