const path = require('path');

module.exports = [
    {
        context: path.resolve(__dirname, './'),
        devtool: 'eval-source-map',
        entry: {
            setup: { import: './src/test/setup.ts', filename: 'test/setup.js', library: { type: 'umd' } },
            dbtest: { import: './src/test/dbtest.ts', filename: 'test/dbtest.js', library: { type: 'umd' } },
            index: { import: './src/index.ts', filename: 'index.js', library: { type: 'module' } },
        },
        mode: 'development',
        module: {
            rules: [{
                test: /\.tsx?$/,
                use: 'ts-loader',
                exclude: [

                ]
            }]
        },
        output: {
            filename: '[name].js',
            path: path.resolve(__dirname, 'build/'),
        },
        experiments: {
            outputModule: true
        },
        resolve: {
            extensions: ['.tsx', '.ts', '.jsx', '.js']
        }
    },
    {
        context: path.resolve(__dirname, './'),
        entry: {
            serviceworker: './src/ServiceWorker.ts'
        },
        output: {
            filename: 'ServiceWorker.js',
            path: path.resolve(__dirname, 'build/'),
            libraryTarget: 'self' // Important for service workers
        },
        module: {
            rules: [{
                test: /\.tsx?$/,
                use: 'ts-loader',
                exclude: /node_modules/
            }]
        },
        resolve: {
            extensions: ['.tsx', '.ts', '.js']
        },
        mode: 'development',
        devtool: 'eval-source-map'
    }
]