text: const path = require('path')
  const webpack = require('webpack')
  const MiniCssExtractPlugin = require('mini-css-extract-plugin')
  const UglifyJsPlugin = require('uglifyjs-webpack-plugin')
  
  const env = process.env.NODE_ENV || 'production'
  
  module.exports = {
    entry: ['./src/index.js'],
    resolve: {
      modules: ['../src', '../node_modules'].map(p => path.resolve(__dirname, p)),
    },
    devtool: env === 'production' ? 'none' : 'eval-source-map',
    output: {
      path: path.join(__dirname, '../lib'),
      filename: 'index.js',
      publicPath: '/lib/',
      library: ['webchat'],
      libraryTarget: 'umd',
      globalObject: 'typeof self !== \'undefined\' ? self : this',
    },
    module: {
      rules: [
        {
          test: /\.js$/,
          loader: 'babel-loader',
          exclude: /node-modules/,
          options: {
            cacheDirectory: true,
          },
        },
        {
          test: /\.scss$/,
          loader: [
            MiniCssExtractPlugin.loader,
            'css-loader',
            'sass-loader',
          ],
          exclude: /node_modules/,
        },
      ],
    },
  
    plugins: [
      new webpack.NamedModulesPlugin(),
      new webpack.optimize.OccurrenceOrderPlugin(),
      new UglifyJsPlugin({
        sourceMap: true,
      }),
      new MiniCssExtractPlugin({ filename: '[name].scss' }),
  
      new webpack.DefinePlugin({
        'process.env': { NODE_ENV: JSON.stringify(env) },
      }),
    ],
  }
  