const CopyWebpackPlugin = require('copy-webpack-plugin');

/*
  See:
    https://github.com/superRaytin/react-monaco-editor
*/
module.exports = (baseConfig, env, defaultConfig) => {
  defaultConfig.plugins.push(
    new CopyWebpackPlugin([
      {
        from: 'node_modules/monaco-editor/min/vs',
        to: 'vs',
      },
    ]),
  );

  defaultConfig.module.rules.push({
    test: /\.d\.ts$/,
    use: 'raw-loader',
  });

  defaultConfig.node = {
    fs: 'empty',
  };

  return defaultConfig;
};
