<commit_before>import fs from 'fs';
import path from 'path';
import autoprefixer from 'autoprefixer';
import flexbugs from 'postcss-flexbugs-fixes';
import webpack from 'webpack';
import webpackMiddleware from 'koa-webpack';
import { GenerateSW } from 'workbox-webpack-plugin';

import hasConfig from '../shared/utils/hasConfig';
import logger from '../shared/utils/logger';

export default (app, options) => {
  const hasRenderingConfig = hasConfig(options.appLocation, 'rendering');
  let devConfig = {
    mode: 'development',
    resolve: {
      alias: {
        fervorAppRoutes: path.resolve(options.appLocation, 'src', 'urls.js'),
        fervorConfigRendering: hasRenderingConfig ?
          path.join(options.appLocation, 'src', 'config', 'rendering.js') :
          path.join(__dirname, 'renderingConfig.js'),
      },
    },
    entry: [
      path.join(__dirname, '..', 'client', 'main.js'),
    ],
    output: {
      path: options.appLocation,
      publicPath: '/build/',
      filename: 'bundle.js',
      sourceMapFilename: 'bundle.js.map',
    },
    devtool: 'inline-source-map',
    module: {
      rules: [
        {
          test: /\.json$/,
          exclude: /node_modules/,
          use: 'json-loader',
        },
        {
          test: /\.jpe?g$|\.gif$|\.png$|\.svg$|\.woff$|\.ttf$|\.wav$|\.mp3$|\.html$/,
          loader: 'file-loader',
        },
        {
          test: /\.scss$/,
          use: [
            'style-loader',
            {
              loader: 'css-loader',
              options: {
                modules: true,
                importLoaders: 2,
                localIdentName: '[name]__[local]___[hash:base64:5]',
              },
            },
            {
              loader: 'postcss-loader',
              options: {
                plugins() {
                  return [autoprefixer, flexbugs];
                },
              },
            },
            {
              loader: 'sass-loader',
              options: {
                outputStyle: 'compressed',
              },
            },
          ],
        },
        {
          test: /\.js$/,
          use: [
            {
              loader: 'babel-loader',
              // eslint-disable-next-line global-require
              options: require('./babelrcHelper').default(
                false,
                options.appLocation,
                true,
                ['react-hot-loader/babel'],
              ),
            },
          ],
          exclude: [/node_modules/],
        },
      ],
    },
    plugins: [
      new webpack.DefinePlugin({<commit_msg>Build the scss the same way on the client and server<commit_after>import fs from 'fs';
import path from 'path';
import autoprefixer from 'autoprefixer';
import flexbugs from 'postcss-flexbugs-fixes';
import MiniCSSExtractPlugin from 'mini-css-extract-plugin';
import webpack from 'webpack';
import webpackMiddleware from 'koa-webpack';
import { GenerateSW } from 'workbox-webpack-plugin';

import hasConfig from '../shared/utils/hasConfig';
import logger from '../shared/utils/logger';

export default (app, options) => {
  const hasRenderingConfig = hasConfig(options.appLocation, 'rendering');
  let devConfig = {
    mode: 'development',
    resolve: {
      alias: {
        fervorAppRoutes: path.resolve(options.appLocation, 'src', 'urls.js'),
        fervorConfigRendering: hasRenderingConfig ?
          path.join(options.appLocation, 'src', 'config', 'rendering.js') :
          path.join(__dirname, 'renderingConfig.js'),
      },
    },
    entry: [
      path.join(__dirname, '..', 'client', 'main.js'),
    ],
    output: {
      path: options.appLocation,
      publicPath: '/build/',
      filename: 'bundle.js',
      sourceMapFilename: 'bundle.js.map',
    },
    devtool: 'inline-source-map',
    module: {
      rules: [
        {
          test: /\.json$/,
          exclude: /node_modules/,
          use: 'json-loader',
        },
        {
          test: /\.jpe?g$|\.gif$|\.png$|\.svg$|\.woff$|\.ttf$|\.wav$|\.mp3$|\.html$/,
          loader: 'file-loader',
        },
        {
          test: /\.scss$/,
          use: [
            MiniCSSExtractPlugin.loader,
            {
              loader: 'css-loader',
              options: {
                modules: true,
                importLoaders: 2,
                localIdentName: '[name]__[local]___[hash:base64:5]',
              },
            },
            {
              loader: 'postcss-loader',
              options: {
                plugins() {
                  return [autoprefixer, flexbugs];
                },
              },
            },
            {
              loader: 'sass-loader',
              options: {
                outputStyle: 'compressed',
              },
            },
          ],
        },
        {
          test: /\.js$/,
          use: [
            {
              loader: 'babel-loader',
              // eslint-disable-next-line global-require
              options: require('./babelrcHelper').default(
                false,
                options.appLocation,
                true,
                ['react-hot-loader/babel'],
              ),
            },
          ],
          exclude: [/node_modules/],
        },
      ],
    },
    plugins: [
      new MiniCSSExtractPlugin({
        filename: 'bundle-[chunkhash:6].css',
      }),
      new webpack.DefinePlugin({
{'fraction_non_alphanumeric': 0.1450508788159112, 'fraction_numerical': 0.0020351526364477336, 'mean_word_length': 1.462870159453303, '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': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5279855', 'n_tokens_mistral': 1569, 'n_tokens_neox': 1539, 'n_words': 281}