text: // @ts-check
  const path = require('path');
  const webpack = require('webpack');
  const yargs = require('yargs');
  const CopyWebpackPlugin = require('copy-webpack-plugin');
  const CircularDependencyPlugin = require('circular-dependency-plugin');
  
  const outputPath = path.resolve(__dirname, 'lib');
  const { mode }  = yargs.option('mode', {
      description: "Mode to use",
      choices: ["development", "production"],
      default: "production"
  }).argv;
  const development = mode === 'development';
  
  module.exports = {
      entry: path.resolve(__dirname, 'src-gen/frontend/index.js'),
      output: {
          filename: 'bundle.js',
          path: outputPath
      },
      target: 'web',
      mode,
      node: {
          fs: 'empty',
          child_process: 'empty',
          net: 'empty',
          crypto: 'empty'
      },
      module: {
          rules: [
              {
                  test: /worker-main\.js$/,
                  loader: 'worker-loader',
                  options: {
                      name: 'worker-ext.[hash].js'
                  }
              },
              {
                  test: /\.css$/,
                  exclude: /\.useable\.css$/,
                  loader: 'style-loader!css-loader'
              },
              {
                  test: /\.useable\.css$/,
                  loader: 'style-loader/useable!css-loader'
              },
              {
                  test: /\.(ttf|eot|svg)(\?v=\d+\.\d+\.\d+)?$/,
                  loader: 'url-loader?limit=10000&mimetype=image/svg+xml'
              },
              {
                  test: /\.(jpg|png|gif)$/,
                  loader: 'file-loader',
                  options: {
                      name: '[path][name].[hash].[ext]',
                  }
              },
              {
                  // see https://github.com/theia-ide/theia/issues/556
                  test: /source-map-support/,
                  loader: 'ignore-loader'
              },
              {
                  test: /\.js$/,
                  enforce: 'pre',
                  loader: 'source-map-loader',
                  exclude: /jsonc-parser|fast-plist|onigasm|(monaco-editor.*)/
              },
              {
                  test: /\.woff(2)?(\?v=[0-9]\.[0-9]\.[0-9])?$/,
                  loader: "url-loader?limit=10000&mimetype=application/font-woff"
              },
              {
                  test: /node_modules[\\|/](vscode-languageserver-types|vscode-uri|jsonc-parser)/,
                  use: { loader: 'umd-compat-loader' }
              },
              {
                  test: /\.wasm$/,
                  loader: "file-loader",
                  type: "javascript/auto",
              },
              {
                  test: /\.plist$/,
                  loader: "file-loader",
              },
          ]
      },
      resolve: {
          extensions: ['.js']
      },
      devtool: 'source-map',
      plugins: [
          new CopyWebpackPlugin([
          ]),
          new CircularDependencyPlugin({
              exclude: /(node_modules|examples)\/./,
              failOnError: false // https://github.com/nodejs/readable-stream/issues/280#issuecomment-297076462
          }),
      ],
      stats: {
          warnings: true
      }
  };