const path = require('path')
const webpack = require('webpack')
const isDevelopment = process.env.NODE_ENV !== 'production';
const package = require('./package.json');


//https://github.com/webpack/webpack/tree/master/examples/dll

//build a vendor.dll file that is "static" (only needs to be changed if we add a package to package.json)
//this way we *should* increase the bundle speed for development

module.exports = {
  mode: "development",
  context: process.cwd(),
  resolve: {
    extensions: [".js", ".json", ".css"],
    modules: [__dirname, 'node_modules']
  },

  entry: {
    vendor: Object.keys(package.dependencies)
      //mathjax is included via script tag
      .filter(p => p !== 'mathjax')
      .concat([
        "externalLibsForBundling/brace/themes/monokai_changed.js",
      ])
  },
  output: {
    filename: '[name].dll.js',
    path: path.resolve(__dirname, './dist_nocopy'),
    library: '[name]_[hash]'
  },
  module: {
    rules: [
      {
        test: /\.css$/,
        loaders: [
          'style-loader',
          'css-loader'
        ]
      }
    ]
  },
  plugins: [
    new webpack.DllPlugin({
      name: '[name]_[hash]',
      path: './dist_nocopy/vendor_manifest.json'
    })
  ]
};