import path from 'path';
import HtmlWebpackPlugin from 'html-webpack-plugin';
import webpack from 'webpack';
import CopyWebpackPlugin from 'copy-webpack-plugin';

export default {
  devtool: 'inline-source-map',
  mode: 'development',
  entry: [
    path.resolve(__dirname, 'src/main.js')
  ],
  target: 'web',
  output: {
    path: path.resolve(__dirname, 'www'),
    publicPath: '/',
    filename: 'bundle.js'
  },
  plugins: [
    new webpack.DefinePlugin({
      CANVAS_RENDERER: JSON.stringify(true),
      WEBGL_RENDERER: JSON.stringify(true)
    }),
    // Create HTML file that includes reference to bundled JS.
    new HtmlWebpackPlugin({
      template: 'src/index.html',
      filename:'index.html',
      inject: true
    }),
    new CopyWebpackPlugin([
      {from:'src/assets',to:'assets'}
    ])
  ],
  module: {
    rules: [
      { test: /\.js$/, exclude: /node_modules/, loaders: "babel-loader" },
      {
        test: /\.(gif|png|jpe?g|svg|xml)$/i,
        use: "file-loader"
      },
      {
        test: [/\.vert$/, /\.frag$/],
        use: "raw-loader"
      }
    ]
  }
};
