const path = require('path');
const webpack = require('webpack');
const Dotenv = require('dotenv-webpack');

module.exports = {
    mode: process.env.WEBPACK_MODE,
    entry: './src/index.js',
    output: {
      filename: 'main.js',
      path: path.resolve(__dirname, 'public/dist'),
      publicPath: '/dist/',
    },
    devServer: {
      hot: true,
      watchFiles: ['src/**/*'],
      client: {
          logging: 'verbose',
          overlay: true,
          progress: true,
          webSocketURL: 'ws://0.0.0.0:' + process.env.DEV_PORT + '/ws'
      },
      static: [
        {
            directory: path.join(__dirname, 'public'),
            watch: true
        },
        {
            directory: path.join(__dirname, process.env.HTTP_FOLDER ? process.env.HTTP_FOLDER : 'www'),
            watch: false,
            publicPath: '/data'
        },
      ],
      port: 9000
    },
    plugins: [
      new webpack.IgnorePlugin({
        /* cf https://gitlab.tetras-libre.fr/iiif/mirador-video-annotation/-/blob/annotation-on-video/webpack.config.js#L42 */
        resourceRegExp: /@blueprintjs\/(core|icons)/, // ignore optional UI framework dependencies
      }),
      new Dotenv()
    ]
};