const path = require('path');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const HTMLWebpackPlugin = require('html-webpack-plugin');
const TerserWebpackPlugin = require('terser-webpack-plugin');
const Package = require('./package');

module.exports = {
  entry: './src/game/index.js',
  devtool: 'inline-source-map',
  performance: {
    hints: false
  },
  optimization: {
    minimizer: [new TerserWebpackPlugin()]
  },
  "plugins": [
    new HTMLWebpackPlugin({
      title: Package.name,
      template: path.join(__dirname, "src/game/index.html")
    }),
    new CopyWebpackPlugin({
      patterns: [
        { from: 'assets', to: 'assets' },
      ]
    })
  ],
  module: {
    rules: [
      {
        test: /\.js?$/,
        exclude: /node_modules/
      }
    ]
  },
  resolve: {
    extensions: ['.ts', '.js']
  },
  output: {
    filename: 'game.js',
    path: path.resolve(__dirname, 'app_web')
  }
};