const Encore = require('@symfony/webpack-encore');

if (!Encore.isRuntimeEnvironmentConfigured()) {
  Encore.configureRuntimeEnvironment(process.env.NODE_ENV || 'dev');
}

Encore
  // where compiled assets will be stored
  .setOutputPath('public/build/')
  // public path used by the web server to access the output path
  .setPublicPath('/build')
  // clean output before build
  .cleanupOutputBeforeBuild()
  // main entry for your app
  .addEntry('app', './assets/app.js')
  .addEntry('game1', './assets/game1.js')
  // split entry chunks for better caching
  .splitEntryChunks()
  // will require an extra script tag for runtime.js
  .enableSingleRuntimeChunk()
  // features
  .enableSourceMaps(!Encore.isProduction())
  .enableVersioning(Encore.isProduction())
  // Babel config for wide browser support
  .configureBabelPresetEnv((options) => {
    options.useBuiltIns = 'usage';
    options.corejs = 3;
    options.bugfixes = true;
  })
  .autoProvidejQuery(false)
  .enableBuildNotifications()
;

module.exports = Encore.getWebpackConfig();
