const defaultConfig = require('@wordpress/scripts/config/webpack.config');
const path = require('path');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');

module.exports = {
    ...defaultConfig,
    entry: {
        'ipag-gateway-blocks': [
            path.resolve(process.cwd(), 'js/ipag-gateway-blocks.js'),
            path.resolve(process.cwd(), 'scss/ipag-gateway-blocks.scss'),
        ],
        'ipag-gateway_pix-blocks': path.resolve(process.cwd(), 'js/ipag-gateway_pix-blocks.js'),
        'ipag-gateway_boleto-blocks': path.resolve(process.cwd(), 'js/ipag-gateway_boleto-blocks.js'),
    },
    output: {
        ...defaultConfig.output,
        path: path.resolve(process.cwd(), 'js/blocks/'),
        filename: '[name].min.js',
    },
    plugins: [
        ...(defaultConfig.plugins || []),
        new MiniCssExtractPlugin({ filename: '[name].min.css' }),
    ],
    externals: {
        '@woocommerce/blocks-registry': ['wc', 'wcBlocksRegistry'],
        '@woocommerce/settings': ['wc', 'wcSettings'],
        '@woocommerce/blocks-checkout': ['wc', 'wcBlocksCheckout'],
        '@wordpress/element': 'wp.element',
        '@wordpress/i18n': 'wp.i18n',
        '@wordpress/html-entities': 'wp.htmlEntities',
        '@wordpress/components': 'wp.components',
    },
};