const path = require('path');

module.exports = {
	mode: 'production',
	entry: {
		'admin/main': './src/admin/index.jsx',
		'admin/deactivation-feedback': './src/admin/deactivation-feedback.jsx',
		'checkout/digitalapps-payments-for-adyen-card-init': './assets/js/digitalapps-payments-for-adyen-card-init.js',
	},
	output: {
		path: path.resolve(__dirname, 'build'),
		filename: '[name].js',
	},
	module: {
		rules: [
			{
				test: /\.jsx?$/,
				exclude: /node_modules/,
				use: {
					loader: 'babel-loader',
					options: {
						presets: ['@babel/preset-env', ['@babel/preset-react', { runtime: 'classic' }]],
					},
				},
			},
			{
				test: /\.css$/,
				use: ['style-loader', 'css-loader'],
			},
		],
	},
	resolve: {
		extensions: ['.js', '.jsx'],
	},
	externals: {
		react: 'React',
		'react-dom': 'ReactDOM',
		'react-dom/client': 'ReactDOM',
		'@wordpress/i18n': ['wp', 'i18n'],
	},
};
