var HtmlWebpackPlugin = require('html-webpack-plugin');
const path = require('path')
const webpack = require('webpack')
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;


module.exports = {
    mode: "development", 
    entry: {
        "bundle": __dirname + "/src/index", 
        "demobundle": __dirname + "/src/consentDemo"
    }, 
    output: {
        filename: '[name].js',
        path: __dirname + "/dist"
    },
    plugins: [
        new HtmlWebpackPlugin({
            title: 'signatu consent react demo',
            template: 'index.template.ejs',
            inject: 'body'
        }), 
        /** Exclude moment.js locales */
        new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/), 
        new BundleAnalyzerPlugin({
            analyzerPort: "8890"
        })
    ],

    // Enable sourcemaps for debugging webpack's output.
    devtool: "source-map",

    resolve: {
        extensions: [".webpack.js", ".web.js", ".ts", ".tsx", ".js", ".css"]
    },

    module: {
        rules: [
            { 
                enforce: 'pre', 
                test: /\.js$/, 
                loader: "source-map-loader",
                "exclude": [
                    path.join(process.cwd(), 'node_modules')
                ]
            },
            { test: /\.tsx?$/, loader: "ts-loader" },
            { test: /\.css$/, loaders: ["style-loader", "css-loader"]}        
        ]
    }
};
