<commit_before>require('dotenv').config();
const path = require('path');
const webpack = require('webpack');

const ExtractTextPlugin = require('extract-text-webpack-plugin');
const FriendlyErrorsWebpackPlugin = require('friendly-errors-webpack-plugin');
const WebpackNotifierPlugin = require('webpack-notifier');
const CleanWebpackPlugin = require('clean-webpack-plugin');
const StatsWriterPlugin = require('webpack-stats-plugin').StatsWriterPlugin;
const BrowserSyncPlugin = require('browser-sync-webpack-plugin');

const production = process.env.NODE_ENV === 'production';
const hmr = process.argv.includes('--hot');

const expressPort = parseInt(process.env.PORT || '3000', 10);
const webpackDevServerPort = parseInt(process.env.WEBPACKDEVSERVER_PORT || '5000', 10);
const browserSyncPort = parseInt(process.env.BROWSERSYNC_PORT || '7000', 10);
const browserSyncHost = process.env.BROWSERSYNC_HOST || 'localhost';

const extractSass = new ExtractTextPlugin({
  filename: production ? 'dist/css/[name].[contenthash].css' : 'css/[name].css',
  allChunks: true,
  disable: hmr
});

const sassSourceMap = production || (process.env.SASS_SOURCE_MAP || false);

module.exports = {
  entry: {
    app: [
      './assets/js/app.js',
      './assets/sass/app.scss'
    ],
    vendor: [
      'lodash',
      'jquery',
      'vue',
      'axios',
      'sweetalert2',
      'slick-carousel'
    ]
  },
  output: {
    path: path.join(__dirname, '/public'),
    filename: production ? 'dist/js/[name].[chunkhash].js' : 'js/[name].js',
    publicPath: hmr ? `http://localhost:${webpackDevServerPort}/` : '/'
  },
  module: {
    rules: [
      {
        test: /\.scss$/,
        use: extractSass.extract({
          use: [{
            loader: 'css-loader',
            options: {
              sourceMap: sassSourceMap
            }
          }, {
            loader: `resolve-url-loader${sassSourceMap ? '?sourceMap' : ''}`
          }, {
            loader: 'sass-loader',
            options: {
              precision: 8,
              outputStyle: 'expanded',
              sourceMap: sassSourceMap
            }
          }],
          fallback: 'style-loader'
        })
      },
      {
        test: /\.vue$/,
        loader: 'vue-loader',
        options: {
          loaders: {
            js: 'babel-loader?cacheDirectory',
            scss: 'vue-style-loader!css-loader!sass-loader',
            sass: 'vue-style-loader!css-loader!sass-loader?indentedSyntax'
          }
        }
      },
      {
        test: /\.jsx?$/,
        exclude: /(node_modules|bower_components)/,
        use: 'babel-loader?cacheDirectory'
      },
      {
        test: /\.html$/,
        loaders: ['html-loader']
      },
      {
        test: /\.(png|jpe?g|gif)$/,
        loaders: [
          {
            loader: 'file-loader',
            options: {
              name: 'images/[name].[ext]?[hash]',
              publicPath: '/'
            }
          },
          'img-loader'
        ]
      },
      {
        test: /\.(woff2?|ttf|eot|svg|otf)$/,
        loader: 'file-loader',
        options: {
          name: 'fonts/[name].[ext]?[hash]'
        }
      }
    ]
  },
  plugins: [
    new FriendlyErrorsWebpackPlugin(),
    new webpack.LoaderOptionsPlugin({
      minimize: production,
      options: {
        context: __dirname,
        output: { path: './' }
      }
    }),
    new WebpackNotifierPlugin(),
    new webpack.optimize.CommonsChunkPlugin({
      names: ['vendor', 'manifest'],
      minChunks: Infinity
    }),
    extractSass,
    new webpack.DefinePlugin({
      'process.env': {
        NODE_ENV: JSON.stringify('production')
      }
    }),
    new BrowserSyncPlugin(
      {
        host: browserSyncHost,
        port: browserSyncPort,
        open: browserSyncHost === 'localhost' ? 'local' : 'external',
        proxy: `http://${browserSyncHost}:${expressPort}/`,
        files: [
          'public/js/**/*.js',
          'public/css/**/*.css'
        ]
      },
      {
        reload: false
      }
    )
  ],
  resolve: {
    alias: {
      vue$: 'vue/dist/vue.common.js'
    }
  },
  performance: {
    hints: false
  },
  devtool: production ? 'source-map' : 'inline-source-map'
};

let plugins = [];

if (hmr) {
  module.exports.entry.app.push(
    `webpack-dev-server/client?http://localhost:${webpackDevServerPort}/`,
    'webpack/hot/dev-server'
  );

  plugins = [
    new webpack.HotModuleReplacementPlugin(),
    new webpack.NoEmitOnErrorsPlugin(),
    new webpack.NamedModulesPlugin()
  ];
}

if (production) {
  plugins = [
    new CleanWebpackPlugin(['dist'], {
      root: path.join(__dirname, '/public')
    }),
    new webpack.optimize.UglifyJsPlugin({
      sourceMap: true,
      compress: {
        warnings: false
      }
    }),
    new StatsWriterPlugin({
      filename: 'assets-manifest.json',
      transform(data) {
        return JSON.stringify({
          '/js/manifest.js': `/${data.assetsByChunkName.manifest[0]}`,
          '/js/vendor.js': `/${data.assetsByChunkName.vendor[0]}`,
          '/js/app.js': `/${data.assetsByChunkName.app[0]}`,<commit_msg>fix vue devtools<commit_after>require('dotenv').config();
const path = require('path');
const webpack = require('webpack');

const ExtractTextPlugin = require('extract-text-webpack-plugin');
const FriendlyErrorsWebpackPlugin = require('friendly-errors-webpack-plugin');
const WebpackNotifierPlugin = require('webpack-notifier');
const CleanWebpackPlugin = require('clean-webpack-plugin');
const StatsWriterPlugin = require('webpack-stats-plugin').StatsWriterPlugin;
const BrowserSyncPlugin = require('browser-sync-webpack-plugin');

const production = process.env.NODE_ENV === 'production';
const hmr = process.argv.includes('--hot');

const expressPort = parseInt(process.env.PORT || '3000', 10);
const webpackDevServerPort = parseInt(process.env.WEBPACKDEVSERVER_PORT || '5000', 10);
const browserSyncPort = parseInt(process.env.BROWSERSYNC_PORT || '7000', 10);
const browserSyncHost = process.env.BROWSERSYNC_HOST || 'localhost';

const extractSass = new ExtractTextPlugin({
  filename: production ? 'dist/css/[name].[contenthash].css' : 'css/[name].css',
  allChunks: true,
  disable: hmr
});

const sassSourceMap = production || (process.env.SASS_SOURCE_MAP || false);

module.exports = {
  entry: {
    app: [
      './assets/js/app.js',
      './assets/sass/app.scss'
    ],
    vendor: [
      'lodash',
      'jquery',
      'vue',
      'axios',
      'sweetalert2',
      'slick-carousel'
    ]
  },
  output: {
    path: path.join(__dirname, '/public'),
    filename: production ? 'dist/js/[name].[chunkhash].js' : 'js/[name].js',
    publicPath: hmr ? `http://localhost:${webpackDevServerPort}/` : '/'
  },
  module: {
    rules: [
      {
        test: /\.scss$/,
        use: extractSass.extract({
          use: [{
            loader: 'css-loader',
            options: {
              sourceMap: sassSourceMap
            }
          }, {
            loader: `resolve-url-loader${sassSourceMap ? '?sourceMap' : ''}`
          }, {
            loader: 'sass-loader',
            options: {
              precision: 8,
              outputStyle: 'expanded',
              sourceMap: sassSourceMap
            }
          }],
          fallback: 'style-loader'
        })
      },
      {
        test: /\.vue$/,
        loader: 'vue-loader',
        options: {
          loaders: {
            js: 'babel-loader?cacheDirectory',
            scss: 'vue-style-loader!css-loader!sass-loader',
            sass: 'vue-style-loader!css-loader!sass-loader?indentedSyntax'
          }
        }
      },
      {
        test: /\.jsx?$/,
        exclude: /(node_modules|bower_components)/,
        use: 'babel-loader?cacheDirectory'
      },
      {
        test: /\.html$/,
        loaders: ['html-loader']
      },
      {
        test: /\.(png|jpe?g|gif)$/,
        loaders: [
          {
            loader: 'file-loader',
            options: {
              name: 'images/[name].[ext]?[hash]',
              publicPath: '/'
            }
          },
          'img-loader'
        ]
      },
      {
        test: /\.(woff2?|ttf|eot|svg|otf)$/,
        loader: 'file-loader',
        options: {
          name: 'fonts/[name].[ext]?[hash]'
        }
      }
    ]
  },
  plugins: [
    new FriendlyErrorsWebpackPlugin(),
    new webpack.LoaderOptionsPlugin({
      minimize: production,
      options: {
        context: __dirname,
        output: { path: './' }
      }
    }),
    new WebpackNotifierPlugin(),
    new webpack.optimize.CommonsChunkPlugin({
      names: ['vendor', 'manifest'],
      minChunks: Infinity
    }),
    extractSass,
    new BrowserSyncPlugin(
      {
        host: browserSyncHost,
        port: browserSyncPort,
        open: browserSyncHost === 'localhost' ? 'local' : 'external',
        proxy: `http://${browserSyncHost}:${expressPort}/`,
        files: [
          'public/js/**/*.js',
          'public/css/**/*.css'
        ]
      },
      {
        reload: false
      }
    )
  ],
  resolve: {
    alias: {
      vue$: 'vue/dist/vue.common.js'
    }
  },
  performance: {
    hints: false
  },
  devtool: production ? 'source-map' : 'inline-source-map'
};

let plugins = [];

if (hmr) {
  module.exports.entry.app.push(
    `webpack-dev-server/client?http://localhost:${webpackDevServerPort}/`,
    'webpack/hot/dev-server'
  );

  plugins = [
    new webpack.HotModuleReplacementPlugin(),
    new webpack.NoEmitOnErrorsPlugin(),
    new webpack.NamedModulesPlugin()
  ];
}

if (production) {
  plugins = [
    new CleanWebpackPlugin(['dist'], {
      root: path.join(__dirname, '/public')
    }),
    new webpack.DefinePlugin({
      'process.env': {
        NODE_ENV: JSON.stringify('production')
      }
    }),
    new webpack.optimize.UglifyJsPlugin({
      sourceMap: true,
      compress: {
        warnings: false
      }
    }),
    new StatsWriterPlugin({
      filename: 'assets-manifest.json',
      transform(data) {
        return JSON.stringify({
          '/js/manifest.js': `/${data.assetsByChunkName.manifest[0]}`,
          '/js/vendor.js': `/${data.assetsByChunkName.vendor[0]}`,
          '/js/app.js': `/${data.assetsByChunkName.app[0]}`,
{'fraction_non_alphanumeric': 0.1624107230212308, 'fraction_numerical': 0.004696213677722336, 'mean_word_length': 2.1403993855606758, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, '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': '3663533', 'n_tokens_mistral': 3267, 'n_tokens_neox': 3190, 'n_words': 509}