const path = require('path')
const CleanWebpackPlugin = require('clean-webpack-plugin')
const CopyWebpackPlugin = require('copy-webpack-plugin')

module.exports = {
    context: path.join(__dirname),
    entry: {
        index: './assets/js/index.js',
    },
    output: {
        filename: '[name].js',
        path: path.resolve(__dirname, 'public/js')
    },
    plugins: [
        new CleanWebpackPlugin(['public/js', 'public/css']),
        new CopyWebpackPlugin([
            { from: 'assets/css/vendor/font-awesome', to: '../css/font-awesome' },
            { from: 'assets/css/index.css', to: '../css' },
            { from: 'assets/css/custom/patua-one-font.css', to: '../css' },
            { from: 'assets/img', to: '../img' }
        ])
    ],
    module: {
        rules: [
            {
                test: /\.css$/,
                use: [
                    'style-loader',
                    'css-loader'
                ]
            },
            {
                test: /\.json/,
                loader: 'json-loader'
            }
        ]
    }
}
