import {Configuration} from 'webpack';
import {root} from './tools/helpers';
import {AotPlugin} from '@ngtools/webpack'

const config: Configuration = {
    devtool: 'source-map',

    resolve: {
        extensions: ['.js', '.ts']
    },

    entry: './src/index.ts',

    output: {
        path: root('./dist/bundle'),
        filename: 'rankit-widget.js',
        libraryTarget: 'umd',
        library: 'rankit-widget'
    },

    module: {
        rules: [{
            test: /\.ts$/, loader: '@ngtools/webpack',
            exclude: [/\.(spec|e2e)\.ts$/]
        },
            {
                test: /\.html$/,
                use: ['raw-loader']
            },
            {
                test: /\.css$/,
                use: ['to-string-loader', 'css-loader']
            },
            {
                test: /\.scss$/,
                use: ['to-string-loader', 'css-loader', 'sass-loader']
            }
        ]
    },
    plugins: [
        new AotPlugin({
            tsConfigPath: './tsconfig.bundle.json',
            mainPath: './src/main.ts',
            skipCodeGeneration: true
        })
    ]

};

export default config;
