<commit_before>import webpack, {LoaderOptionsPlugin, DefinePlugin, NoErrorsPlugin, HotModuleReplacementPlugin} from 'webpack'
import path from 'path'

import autoprefixer from 'autoprefixer'
import precss from 'precss'
import smart_import from 'postcss-smart-import'

import ManifestPlugin from 'webpack-manifest-plugin'
import ExtractTextPlugin from 'extract-text-webpack-plugin'
import CaseSensitivePathsPlugin from 'case-sensitive-paths-webpack-plugin'
import CompressionPlugin from 'compression-webpack-plugin'
import HtmlWebpackPlugin from 'html-webpack-plugin'

const {UglifyJsPlugin, CommonsChunkPlugin, OccurrenceOrderPlugin} = webpack.optimize

const cssLoaderOptions = 'modules&minimize=1&importLoaders=1&localIdentName=[path]__[name]_[local]__[hash:base64:8]!postcss'

const ENV = process.env.NODE_ENV || 'development'

const output = {
  path: path.join(__dirname, 'build'),
  pathinfo: true,
  filename: 'static/js/[name].[hash:8].js',
  chunkFilename: 'static/js/[name].[hash:8].chunk.js'
}

const entry = {
  app: './index.js',
  vendor: ['whatwg-fetch']
}

const rules = [
  {
    test: /\.(js|jsx)$/,
    exclude: /node_modules/,
    loader: 'babel',
    query: {
      babelrc: true
    }
  }, {
    test: /\.(ico|jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2)(\?.*)?$/,
    loader: 'file',
    query: {
      name: 'static/media/[name].[hash:8].[ext]'
    }
  },
  // "url" loader works just like "file" loader but it also embeds
  // assets smaller than specified size as data URLs to avoid requests.
  {
    test: /\.(mp4|webm|wav|mp3|m4a|aac|oga)(\?.*)?$/,
    loader: 'url',
    query: {
      limit: 10000,
      name: 'static/media/[name].[hash:8].[ext]'
    }
  }
]

const config = {
  context: path.join(__dirname, 'src'),
  entry,
  output,
  module: {
    rules
  },
  resolve: {
    alias: {
      css: path.join(__dirname, 'src/assets/css'),
      img: path.join(__dirname, 'src/assets/images'),
      fonts: path.join(__dirname, 'src/assets/fonts')
    }
  },
  plugins: [
    new DefinePlugin({ENV: JSON.stringify(ENV)}),
    new CommonsChunkPlugin({name: 'vendor', filename: 'static/js/vendor.[hash:8].js', async: true}),
    new OccurrenceOrderPlugin,
    new LoaderOptionsPlugin({
      debug: ENV === 'development',
      options: {
        postcss: () => [smart_import, precss, autoprefixer]
      }
    }),
    new ManifestPlugin({fileName: 'asset-manifest.json'}),
    new HtmlWebpackPlugin({
      inject: true,
      template: path.join(__dirname, 'public/index.html'),
      minify: {
        removeComments: true,
        collapseWhitespace: true,
        removeRedundantAttributes: true,
        useShortDoctype: true,
        removeEmptyAttributes: true,
        removeStyleLinkTypeAttributes: true,
        keepClosingSlash: true,
        minifyJS: true,
        minifyCSS: true,
        minifyURLs: true
      }
    }),
    new CaseSensitivePathsPlugin,
    new CompressionPlugin({asset: '[path].gz[query]', algorithm: 'gzip', test: /\.js$|\.html$/, threshold: 10240, minRatio: 0.8})
  ],
  bail: true,
  cache: true,
  devtool: 'hidden-source-map'
}

if (ENV === 'development') {
  /************************************************************************
  *                               DEVELOPMENT
  *************************************************************************/

  config.module.rules.push({
    test: /\.(scss|sass|css)$/,
    use: [
      'style-loader', {
        loader: 'css-loader',
        options: {
          modules: 1,
          importLoaders: 1
        }
      }, {<commit_msg>hot-fix: css modules bad naming in dev mode<commit_after>import webpack, {LoaderOptionsPlugin, DefinePlugin, NoErrorsPlugin, HotModuleReplacementPlugin} from 'webpack'
import path from 'path'

import autoprefixer from 'autoprefixer'
import precss from 'precss'
import smart_import from 'postcss-smart-import'

import ManifestPlugin from 'webpack-manifest-plugin'
import ExtractTextPlugin from 'extract-text-webpack-plugin'
import CaseSensitivePathsPlugin from 'case-sensitive-paths-webpack-plugin'
import CompressionPlugin from 'compression-webpack-plugin'
import HtmlWebpackPlugin from 'html-webpack-plugin'

const {UglifyJsPlugin, CommonsChunkPlugin, OccurrenceOrderPlugin} = webpack.optimize

const cssLoaderOptions = 'modules&minimize=1&importLoaders=1&localIdentName=[path]__[name]_[local]__[hash:base64:8]!postcss'

const ENV = process.env.NODE_ENV || 'development'

const output = {
  path: path.join(__dirname, 'build'),
  pathinfo: true,
  filename: 'static/js/[name].[hash:8].js',
  chunkFilename: 'static/js/[name].[hash:8].chunk.js'
}

const entry = {
  app: './index.js',
  vendor: ['whatwg-fetch']
}

const rules = [
  {
    test: /\.(js|jsx)$/,
    exclude: /node_modules/,
    loader: 'babel',
    query: {
      babelrc: true
    }
  }, {
    test: /\.(ico|jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2)(\?.*)?$/,
    loader: 'file',
    query: {
      name: 'static/media/[name].[hash:8].[ext]'
    }
  },
  // "url" loader works just like "file" loader but it also embeds
  // assets smaller than specified size as data URLs to avoid requests.
  {
    test: /\.(mp4|webm|wav|mp3|m4a|aac|oga)(\?.*)?$/,
    loader: 'url',
    query: {
      limit: 10000,
      name: 'static/media/[name].[hash:8].[ext]'
    }
  }
]

const config = {
  context: path.join(__dirname, 'src'),
  entry,
  output,
  module: {
    rules
  },
  resolve: {
    alias: {
      css: path.join(__dirname, 'src/assets/css'),
      img: path.join(__dirname, 'src/assets/images'),
      fonts: path.join(__dirname, 'src/assets/fonts')
    }
  },
  plugins: [
    new DefinePlugin({ENV: JSON.stringify(ENV)}),
    new CommonsChunkPlugin({name: 'vendor', filename: 'static/js/vendor.[hash:8].js', async: true}),
    new OccurrenceOrderPlugin,
    new LoaderOptionsPlugin({
      debug: ENV === 'development',
      options: {
        postcss: () => [smart_import, precss, autoprefixer]
      }
    }),
    new ManifestPlugin({fileName: 'asset-manifest.json'}),
    new HtmlWebpackPlugin({
      inject: true,
      template: path.join(__dirname, 'public/index.html'),
      minify: {
        removeComments: true,
        collapseWhitespace: true,
        removeRedundantAttributes: true,
        useShortDoctype: true,
        removeEmptyAttributes: true,
        removeStyleLinkTypeAttributes: true,
        keepClosingSlash: true,
        minifyJS: true,
        minifyCSS: true,
        minifyURLs: true
      }
    }),
    new CaseSensitivePathsPlugin,
    new CompressionPlugin({asset: '[path].gz[query]', algorithm: 'gzip', test: /\.js$|\.html$/, threshold: 10240, minRatio: 0.8})
  ],
  bail: true,
  cache: true,
  devtool: 'hidden-source-map'
}

if (ENV === 'development') {
  /************************************************************************
  *                               DEVELOPMENT
  *************************************************************************/

  config.module.rules.push({
    test: /\.(scss|sass|css)$/,
    use: [
      'style-loader', {
        loader: 'css-loader',
        options: {
          localIdentName: '[path]__[name]_[local]__[hash:base64:8]',
          modules: 1,
          importLoaders: 1
        }
      }, {
{'fraction_non_alphanumeric': 0.186001386001386, 'fraction_numerical': 0.008177408177408177, 'mean_word_length': 3.287581699346405, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2192135', 'n_tokens_mistral': 2409, 'n_tokens_neox': 2298, 'n_words': 471}