const path = require('path');
const nodeExternals = require('webpack-node-externals');
const CopyWebpackPlugin = require('copy-webpack-plugin');

const config = {
    entry: './src/index.ts',

    target: 'node',
    node: {
        __dirname: false
    },
    //devtool: 'inline-source-map',
    externals: [
        nodeExternals()
    ],
    
    module: {
        rules: [{
            test: /\.js$/,
            use: ['eslint-loader']
        },{
            test: /\.ts$/,
            use: ['ts-loader'],
        },{
            test: /\.css$/,
            use: ['style-loader', 'css-loader']
        },{
            test: /\.(png|jpg|ico)$/,
            loader: 'file-loader',
            options: {
                limit: 10000
            }
        }]
    },
    resolve: {
        extensions: ['.ts', '.js']
    },
    plugins: [
        new CopyWebpackPlugin([{
            from: 'src/css',
            to: 'css'
        },{
            from: 'src/views',
            to: 'views'
        }]
        )
    ],

    output: {
        path: path.resolve(__dirname, 'build'),
        publicPath: '/assets/',
        filename: 'bundle.js'
    },
};

module.exports = config;