<commit_before>/**
 * Wepback configuration for the node server.
 */

const path = require('path');
const fs = require('fs');

const webpack = require('webpack');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const {CheckerPlugin} = require('awesome-typescript-loader');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const CleanWebpackPlugin = require('clean-webpack-plugin');

const externals = {};
fs.readdirSync('node_modules')
  .filter(function(x) {
    return ['.bin'].indexOf(x) === -1;
  })
  .forEach(function(mod) {
    externals[mod] = `commonjs ${mod}`;
  });

const pluginsNode = [
  new CheckerPlugin(),
  new webpack.BannerPlugin({
    banner: 'require("source-map-support").install();',
    raw: true,
  }),
];

const webpackNode = {
  entry: './src/app.js',
  mode: 'development',
  target: 'node',
  node: {
    __dirname: false,
    __filename: false,
  },
  resolve: {
    extensions: ['.ts', '.js'],
  },
  output: {
    path: path.join(__dirname, 'build'),
    filename: 'gateway.js',
  },
  module: {
    rules: [
      {
        test: /\.tsx?$/,
        loader: 'awesome-typescript-loader',
      },
    ],
  },
  devtool: 'sourcemap',
  plugins: pluginsNode,
  externals,
};

const pluginsWeb = [
  new CopyWebpackPlugin([
    {
      from: 'static/**/*',
      to: path.join(__dirname, 'build/'),
      ignore: ['*.js', '*/index.html'],
    },
    {
      from: 'static/js/lib/*',
      to: path.join(__dirname, 'build/'),
    },
    {
      from: 'static/service-worker.js',
      to: path.join(__dirname, 'build/static'),
    },
  ]),
  new UglifyJsPlugin({
    test: /\.js$/,
    sourceMap: true,
  }),
  new webpack.SourceMapDevToolPlugin({
    test: /\.css$/,
    filename: '[file].map',
  }),
  new MiniCssExtractPlugin({
    filename: 'bundle/[hash]-[name].css',
  }),
  new CleanWebpackPlugin(['build/static/bundle']),
  new HtmlWebpackPlugin({
    inject: 'head',
    template: 'static/index.html',
    chunks: ['style', 'app.js'],
  }),
  new HtmlWebpackPlugin({
    template: 'static/signup/index.html',
    filename: 'signup/index.html',
    chunks: ['create-user.js'],
  }),
  new HtmlWebpackPlugin({
    template: 'static/login/index.html',
    filename: 'login/index.html',
    chunks: ['login.js'],
  }),
  new HtmlWebpackPlugin({
    inject: 'head',
    template: 'src/views/authorize.mustache',
    filename: '../views/authorize.mustache',
    chunks: ['authorize.js'],
  }),
  new HtmlWebpackPlugin({
    inject: 'head',
    template: 'src/views/local-token-service.mustache',
    filename: '../views/local-token-service.mustache',
    chunks: ['check-user.js'],
  }),
  new HtmlWebpackPlugin({
    template: 'src/views/tunnel_setup.mustache',
    filename: '../views/tunnel_setup.mustache',
    chunks: ['setup_subdomain.js'],
  }),
];

const webpackWeb = {
  entry: {
    'app.js': ['./static/js/check-user.js', './static/js/app.js'],
    'create-user.js': ['./static/js/create-user.js'],
    'login.js': ['./static/js/check-user.js', './static/js/login.js'],
    'authorize.js': ['./static/js/check-user.js', './static/js/authorize.js'],
    'setup_subdomain.js': ['./static/js/setup_subdomain.js'],
    buildCss: [
      // css for static/index.html
      './static/css/app.css',
      './static/css/things.css',
      './static/css/menu.css',<commit_msg>Load javascript on local token service view (#1046)<commit_after>/**
 * Wepback configuration for the node server.
 */

const path = require('path');
const fs = require('fs');

const webpack = require('webpack');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const {CheckerPlugin} = require('awesome-typescript-loader');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const CleanWebpackPlugin = require('clean-webpack-plugin');

const externals = {};
fs.readdirSync('node_modules')
  .filter(function(x) {
    return ['.bin'].indexOf(x) === -1;
  })
  .forEach(function(mod) {
    externals[mod] = `commonjs ${mod}`;
  });

const pluginsNode = [
  new CheckerPlugin(),
  new webpack.BannerPlugin({
    banner: 'require("source-map-support").install();',
    raw: true,
  }),
];

const webpackNode = {
  entry: './src/app.js',
  mode: 'development',
  target: 'node',
  node: {
    __dirname: false,
    __filename: false,
  },
  resolve: {
    extensions: ['.ts', '.js'],
  },
  output: {
    path: path.join(__dirname, 'build'),
    filename: 'gateway.js',
  },
  module: {
    rules: [
      {
        test: /\.tsx?$/,
        loader: 'awesome-typescript-loader',
      },
    ],
  },
  devtool: 'sourcemap',
  plugins: pluginsNode,
  externals,
};

const pluginsWeb = [
  new CopyWebpackPlugin([
    {
      from: 'static/**/*',
      to: path.join(__dirname, 'build/'),
      ignore: ['*.js', '*/index.html'],
    },
    {
      from: 'static/js/lib/*',
      to: path.join(__dirname, 'build/'),
    },
    {
      from: 'static/service-worker.js',
      to: path.join(__dirname, 'build/static'),
    },
  ]),
  new UglifyJsPlugin({
    test: /\.js$/,
    sourceMap: true,
  }),
  new webpack.SourceMapDevToolPlugin({
    test: /\.css$/,
    filename: '[file].map',
  }),
  new MiniCssExtractPlugin({
    filename: 'bundle/[hash]-[name].css',
  }),
  new CleanWebpackPlugin(['build/static/bundle']),
  new HtmlWebpackPlugin({
    inject: 'head',
    template: 'static/index.html',
    chunks: ['style', 'app.js'],
  }),
  new HtmlWebpackPlugin({
    template: 'static/signup/index.html',
    filename: 'signup/index.html',
    chunks: ['create-user.js'],
  }),
  new HtmlWebpackPlugin({
    template: 'static/login/index.html',
    filename: 'login/index.html',
    chunks: ['login.js'],
  }),
  new HtmlWebpackPlugin({
    inject: 'head',
    template: 'src/views/authorize.mustache',
    filename: '../views/authorize.mustache',
    chunks: ['authorize.js'],
  }),
  new HtmlWebpackPlugin({
    inject: 'head',
    template: 'src/views/local-token-service.mustache',
    filename: '../views/local-token-service.mustache',
    chunks: ['check-user.js'],
  }),
  new HtmlWebpackPlugin({
    template: 'src/views/tunnel_setup.mustache',
    filename: '../views/tunnel_setup.mustache',
    chunks: ['setup_subdomain.js'],
  }),
];

const webpackWeb = {
  entry: {
    'app.js': ['./static/js/check-user.js', './static/js/app.js'],
    'create-user.js': ['./static/js/create-user.js'],
    'login.js': ['./static/js/check-user.js', './static/js/login.js'],
    'check-user.js': ['./static/js/check-user.js'],
    'authorize.js': ['./static/js/check-user.js', './static/js/authorize.js'],
    'setup_subdomain.js': ['./static/js/setup_subdomain.js'],
    buildCss: [
      // css for static/index.html
      './static/css/app.css',
      './static/css/things.css',
      './static/css/menu.css',
{'fraction_non_alphanumeric': 0.20117243351444095, 'fraction_numerical': 0.0008578781812982557, 'mean_word_length': 3.129279811097993, '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': '3780872', 'n_tokens_mistral': 2427, 'n_tokens_neox': 2441, 'n_words': 418}