var nodeExternals = require('webpack-node-externals');
var path = require('path');
const WorkerPlugin = require('worker-plugin');
var webpack = require('webpack');

var webpack_opts = {
  mode: 'development',
  entry: './src/index.ts',
  output: {
    path: path.join(__dirname, 'lib'),
    filename: 'index.js',
    libraryTarget: 'umd',
  },
  target: 'web',
  resolve: {
    extensions: ['.ts', '.js', '.mjs', '.jsx', '.tsx', '.graphql', '.graphqls', '.gql'],
  },
  plugins: [
    new WorkerPlugin(),
    new webpack.WatchIgnorePlugin([
      /\.js$/,
      /\.d\.ts$/
    ])
  ],
  devtool: 'source-map',
  module: {
    rules: [{
      test: /\.tsx?$/,
      loaders: 'ts-loader'
    },
    {
      test: /\.(gql)$/,
      exclude: /node_modules/,
      use: ['graphql-tag/loader']
    },
    {
      test: /\.graphql?/,
      exclude: /node_modules/,
      use: 'raw-loader',
    },
    { test: /\.css$/, loader: 'ignore-loader' },
    ]
  },
  // node: false,
  externals: [
    nodeExternals({ modulesDir: "../../../node_modules" }),
    nodeExternals()
  ]
};

module.exports = webpack_opts;
