text: const path = require('path');
  const nodeExternals = require('webpack-node-externals');
  
  const { CleanWebpackPlugin } = require('clean-webpack-plugin');
  
  const config = {
    target: 'node',
    entry: './src/dir-utils.ts',
    externals: [nodeExternals()],
    output: {
      path: path.resolve(__dirname, './dist'),
      filename: 'dir-utils.js',
      library: 'DirUtils',
      libraryTarget: 'umd',
      umdNamedDefine: true,
    },
    module: {
      rules: [
        {
          test: /\.tsx?$/,
          use: 'ts-loader',
          exclude: /node_modules/,
        },
      ],
    },
    resolve: {
      extensions: ['.tsx', '.ts', '.js'],
    },
    watchOptions: {
      aggregateTimeout: 600,
      ignored: /node_modules/,
    },
    plugins: [
      new CleanWebpackPlugin({
        cleanStaleWebpackAssets: false,
        cleanOnceBeforeBuildPatterns: [path.resolve(__dirname, './dist')],
      }),
    ],
  };
  
  module.exports = (env, argv) => {
    if (argv.mode === 'development') {
      // * add some development rules here
      config.devtool = 'cheap-module-source-map';
    } else if (argv.mode === 'production') {
      // * add some prod rules here
    } else {
      throw new Error('Specify env');
    }
  
    return config;
  };
  