<commit_before>const path = require('path');
const fs = require('fs');
const nodeExternals = require('webpack-node-externals');
const themePath = path.resolve(process.cwd(), 'theme.js');
const theme = fs.existsSync(themePath) ? require(themePath)() : {};
const env = require('node-env-file');
const ExtractTextPlugin = require("extract-text-webpack-plugin");

env(path.resolve(process.cwd(), '.env'));
require.extensions['.less'] = require.extensions['.css'] = () => undefined;

module.exports = {
  reactHotLoader: true,
  debug: false,
  serverURL: `http://localhost:${process.env.PORT}`,
  clientURL: `http://localhost:${process.env.PORT + 1}`,
  additionalServerPaths: [
    path.resolve(__dirname, '..', 'graphql'),
    path.resolve(__dirname, 'server'),
    path.resolve(__dirname, '..', 'src', 'ekhn', 'schema'),
    path.resolve(process.cwd(), 'server')
  ],
  modifyWebpackConfig: (baseConfig, { type }) => {
    if (!baseConfig.resolve.alias) baseConfig.resolve.alias = {};
    baseConfig.resolve.modules.push(path.resolve(__dirname, '..', 'node_modules'));
    baseConfig.resolveLoader.modules.push(path.resolve(__dirname, '..', 'node_modules'));
    baseConfig.entry.main[baseConfig.entry.main.length - 1] = path.resolve(__dirname, type, 'index.js');
    baseConfig.resolve.alias.react = path.resolve(process.cwd(), 'node_modules', 'react');
    baseConfig.resolve.alias['react-dom'] = path.resolve(process.cwd(), 'node_modules', 'react-dom');
    baseConfig.resolve.alias['react-router'] = path.resolve(process.cwd(), 'node_modules', 'react-router-v4-decode-uri');
    baseConfig.resolve.alias.moment = path.resolve(process.cwd(), 'node_modules', 'moment');
    baseConfig.resolve.alias.lodash = path.resolve(process.cwd(), 'node_modules', 'lodash');
    baseConfig.resolve.alias.olymp = path.resolve(__dirname, '..');
    baseConfig.resolve.alias['@root'] = path.resolve(process.cwd());
    baseConfig.resolve.alias['@app'] = path.resolve(process.cwd(), 'app');
    if (type === 'server') {
      baseConfig.externals = [
        path.resolve(__dirname, '..', 'node_modules'),
        path.resolve(process.cwd(), 'node_modules')
      ].map(modulesDir => nodeExternals({
        modulesDir,
        whitelist: [
          'source-map-support/register',
          v => v === 'olymp' || v.indexOf('olymp/') === 0 || v.indexOf('olymp-') === 0,
          /\.(eot|woff|woff2|ttf|otf)$/,
          /\.(svg|png|jpg|jpeg|gif|ico)$/,
          /\.(mp4|mp3|ogg|swf|webp)$/,
          /\.(css|scss|sass|sss|less)$/
        ]
      }));
    }
    // baseConfig.plugins[0].definitions.KYT.PUBLIC_DIR = JSON.stringify(path.resolve(process.cwd(), 'public'));
    baseConfig.module.rules = baseConfig.module.rules.map(x => {
      if (x.loader === 'babel-loader') {
        delete x.exclude;
        x.include = [
          path.resolve(process.cwd(), 'app'),
          path.resolve(__dirname),
          path.resolve(__dirname, '..', 'src'),
        ];
        x.options.plugins.push(require.resolve('babel-plugin-transform-object-rest-spread'));
        x.options.plugins.push(require.resolve('babel-plugin-transform-es2015-destructuring'));
        x.options.plugins.push(require.resolve('babel-plugin-transform-decorators-legacy'));
        x.options.plugins.push(require.resolve('babel-plugin-transform-class-properties'));
        if (type === 'client') x.options.plugins.push([require.resolve('babel-plugin-import'), { libraryName: 'antd', style: true }]);
      } return x;
    });

    // TODO production client
    baseConfig.module.rules.forEach(x => {
      if (String(x.test) === String(/\.css$/)) {
        if (Array.isArray(x.use)) {
          x.use.filter(u => typeof u === 'object').forEach(u => {
            if (u.options && u.options.modules) u.options.modules = false;
          });
        }
      }
    });
    baseConfig.module.rules.push({
      test: /\.less$/,
      use: type === 'client' ? ExtractTextPlugin.extract({
        fallbackLoader: 'style-loader',
        loader: `css-loader!less-loader?{"modifyVars":${JSON.stringify(theme)}}`,
      }) : [require.resolve('empty-loader')],
    });
    return baseConfig;<commit_msg>no message<commit_after>const path = require('path');
const fs = require('fs');
const nodeExternals = require('webpack-node-externals');
const themePath = path.resolve(process.cwd(), 'theme.js');
const theme = fs.existsSync(themePath) ? require(themePath)() : {};
const env = require('node-env-file');
const ExtractTextPlugin = require("extract-text-webpack-plugin");

env(path.resolve(process.cwd(), '.env'));
require.extensions['.less'] = require.extensions['.css'] = () => undefined;

module.exports = {
  reactHotLoader: true,
  debug: false,
  serverURL: `http://localhost:${process.env.PORT}`,
  clientURL: `http://localhost:${process.env.PORT + 1}`,
  additionalServerPaths: [
    path.resolve(__dirname, '..', 'graphql'),
    path.resolve(__dirname, 'server'),
    path.resolve(__dirname, '..', 'src', 'ekhn', 'schema'),
    path.resolve(process.cwd(), 'server')
  ],
  modifyWebpackConfig: (baseConfig, { type }) => {
    if (!baseConfig.resolve.alias) baseConfig.resolve.alias = {};
    baseConfig.resolve.modules.push(path.resolve(__dirname, '..', 'node_modules'));
    baseConfig.resolveLoader.modules.push(path.resolve(__dirname, '..', 'node_modules'));
    baseConfig.entry.main[baseConfig.entry.main.length - 1] = path.resolve(__dirname, type, 'index.js');
    baseConfig.resolve.alias.react = path.resolve(process.cwd(), 'node_modules', 'react');
    baseConfig.resolve.alias['react-dom'] = path.resolve(process.cwd(), 'node_modules', 'react-dom');
    baseConfig.resolve.alias['react-router'] = path.resolve(process.cwd(), 'node_modules', 'react-router-v4-decode-uri');
    baseConfig.resolve.alias.moment = path.resolve(process.cwd(), 'node_modules', 'moment');
    baseConfig.resolve.alias.lodash = path.resolve(process.cwd(), 'node_modules', 'lodash');
    baseConfig.resolve.alias.olymp = path.resolve(__dirname, '..');
    baseConfig.resolve.alias['@root'] = path.resolve(process.cwd());
    baseConfig.resolve.alias['@app'] = path.resolve(process.cwd(), 'app');
    if (type === 'server') {
      baseConfig.externals = [
        path.resolve(__dirname, '..', 'node_modules'),
        path.resolve(process.cwd(), 'node_modules')
      ].map(modulesDir => nodeExternals({
        modulesDir,
        whitelist: [
          'source-map-support/register',
          v => v === 'olymp' || v.indexOf('olymp/') === 0 || v.indexOf('olymp-') === 0,
          /\.(eot|woff|woff2|ttf|otf)$/,
          /\.(svg|png|jpg|jpeg|gif|ico)$/,
          /\.(mp4|mp3|ogg|swf|webp)$/,
          /\.(css|scss|sass|sss|less)$/
        ]
      }));
    }
    // baseConfig.plugins[0].definitions.KYT.PUBLIC_DIR = JSON.stringify(path.resolve(process.cwd(), 'public'));
    baseConfig.module.rules = baseConfig.module.rules.map(x => {
      if (x.loader === 'babel-loader') {
        delete x.exclude;
        x.include = [
          path.resolve(process.cwd(), 'app'),
          path.resolve(__dirname),
          path.resolve(__dirname, '..', 'src'),
        ];
        x.options.plugins.push(require.resolve('babel-plugin-transform-object-rest-spread'));
        x.options.plugins.push(require.resolve('babel-plugin-transform-es2015-destructuring'));
        x.options.plugins.push(require.resolve('babel-plugin-transform-decorators-legacy'));
        x.options.plugins.push(require.resolve('babel-plugin-transform-class-properties'));
        if (type === 'client') x.options.plugins.push([require.resolve('babel-plugin-import'), { libraryName: 'antd', style: true }]);
      } return x;
    });

    // TODO production client
    baseConfig.module.rules.forEach(x => {
      if (String(x.test) === String(/\.css$/)) {
        if (Array.isArray(x.use)) {
          x.use.filter(u => typeof u === 'object').forEach(u => {
            if (u.options && u.options.modules) u.options.modules = false;
          });
        }
      }
    });
    baseConfig.module.rules.push({
      test: /\.less$/,
      use: type === 'client' ? [
        'style-loader',
        { loader: 'css-loader', options: { importLoaders: 1 } },
        `less-loader?{"modifyVars":${JSON.stringify(theme)}}`
      ] : [require.resolve('empty-loader')],
    });
    return baseConfig;
{'fraction_non_alphanumeric': 0.2000240702852329, 'fraction_numerical': 0.0032494885064388015, 'mean_word_length': 3.369085173501577, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1816355', 'n_tokens_mistral': 2687, 'n_tokens_neox': 2621, 'n_words': 356}