<commit_before>const webpack = require('webpack');
const BabiliPlugin = require('babili-webpack-plugin');
var CopyWebpackPlugin = require('copy-webpack-plugin');
// process.traceDeprecation = true;

module.exports = function (env) {
  var config = {
    entry: {
      'background_page': './src/background_page/index.js',
      'content_script': './src/content_script/index.js',
      'content_script_loader': './src/content_script/loader.js',
      'help': './src/help/index.js',
      'options': './src/options/index.js'
    },
    output: {
      path: __dirname + '/dist',
      filename: '[name].js',
      sourceMapFilename: '[name].js.map' // always generate source maps
    },
    devtool: 'source-map',
    module: {
      loaders: [
        {
          test: /\.js$/,
          exclude: /node_modules/,
          loader: 'babel-loader',
          query: {
            // require.resolve needed to work with linked modules
            // (e.g. saka-action in development) or build will fail
            // presets: [require.resolve('babel-preset-stage-3')]
          }
        },
        {
          test: /\.css$/,
          use: ['style-loader', 'css-loader']
        }
      ]
    },
    resolve: {
      modules: [
        './src',
        './node_modules'
      ]
    },
    plugins: [
      new CopyWebpackPlugin([
         { from: 'static' },
         { from: 'src/modes/basic/config.json', to: 'config_basic.json' },
         { from: 'src/modes/basic/default.json', to: 'default_basic.json' },
         { from: 'src/modes/command/config.json', to: 'config_command.json' },
         { from: 'src/modes/command/default.json', to: 'default_command.json' },
         { from: 'src/modes/hints/config.json', to: 'config_hints.json' },
         { from: 'src/modes/hints/default.json', to: 'default_hints.json' },
         { from: 'src/modes/developer/config.json', to: 'config_developer.json' },
         { from: 'src/modes/developer/default.json', to: 'default_developer.json' }
      ])
    ]
  };

  const [mode, platform] = env.split(':');
  const version = require('./static/manifest.json').version;
  // mode controls:
  // 1. SAKA_DEBUG: boolean(true | false)
  //   * true for development builds
  //   * false for production build
  //   If you want something to run only in testing/development, use
  //     if (SAKA_DEBUG) { console.log(variable); }.
  //   All code within will be removed at build time in production builds.
  // platform controls:
  // 1. SAKA_PLATFORM: string('chrome' | 'firefox' | 'edge')<commit_msg>tried to generalize json config file copying but failed, left notes, will try again in the future<commit_after>const webpack = require('webpack');
const BabiliPlugin = require('babili-webpack-plugin');
var CopyWebpackPlugin = require('copy-webpack-plugin');
// process.traceDeprecation = true;

module.exports = function (env) {
  var config = {
    entry: {
      'background_page': './src/background_page/index.js',
      'content_script': './src/content_script/index.js',
      'content_script_loader': './src/content_script/loader.js',
      'help': './src/help/index.js',
      'options': './src/options/index.js'
    },
    output: {
      path: __dirname + '/dist',
      filename: '[name].js',
      sourceMapFilename: '[name].js.map' // always generate source maps
    },
    devtool: 'source-map',
    module: {
      loaders: [
        {
          test: /\.js$/,
          exclude: /node_modules/,
          loader: 'babel-loader',
          query: {
            // require.resolve needed to work with linked modules
            // (e.g. saka-action in development) or build will fail
            // presets: [require.resolve('babel-preset-stage-3')]
          }
        },
        {
          test: /\.css$/,
          use: ['style-loader', 'css-loader']
        }
      ]
    },
    resolve: {
      modules: [
        './src',
        './node_modules'
      ]
    },
    plugins: [
      new CopyWebpackPlugin([
         { from: 'static' },
         { from: 'src/modes/basic/config.json', to: 'config_basic.json' },
         { from: 'src/modes/basic/default.json', to: 'default_basic.json' },
         { from: 'src/modes/command/config.json', to: 'config_command.json' },
         { from: 'src/modes/command/default.json', to: 'default_command.json' },
         { from: 'src/modes/hints/config.json', to: 'config_hints.json' },
         { from: 'src/modes/hints/default.json', to: 'default_hints.json' },
         { from: 'src/modes/developer/config.json', to: 'config_developer.json' },
         { from: 'src/modes/developer/default.json', to: 'default_developer.json' }
        // TODO: consider replacing lines above to be more generic if transform below ever gets merged
        // https://github.com/kevlened/copy-webpack-plugin/pull/115
        // {
        //   context: 'src/modes',
        //   from: '**/default.json,
        //   to: '[path].json'
        // }
      ])
    ]
  };

  const [mode, platform] = env.split(':');
  const version = require('./static/manifest.json').version;
  // mode controls:
  // 1. SAKA_DEBUG: boolean(true | false)
  //   * true for development builds
  //   * false for production build
  //   If you want something to run only in testing/development, use
  //     if (SAKA_DEBUG) { console.log(variable); }.
  //   All code within will be removed at build time in production builds.
  // platform controls:
  // 1. SAKA_PLATFORM: string('chrome' | 'firefox' | 'edge')
{'fraction_non_alphanumeric': 0.16215722120658135, 'fraction_numerical': 0.0016453382084095063, 'mean_word_length': 2.220129487934079, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '871352', 'n_tokens_mistral': 1731, 'n_tokens_neox': 1683, 'n_words': 369}