const Encore = require('@symfony/webpack-encore');

if (!Encore.isRuntimeEnvironmentConfigured()) {
	Encore.configureRuntimeEnvironment(process.env.NODE_ENV || 'dev');
}

Encore

	// ----------------------------------------------------------------------------
	// PATHS
	// ----------------------------------------------------------------------------

	.setOutputPath('public/assets/build/')
	.setPublicPath('/assets/build')

	// ----------------------------------------------------------------------------
	// ENTRIES
	// ----------------------------------------------------------------------------

	.addEntry('app', './public/assets/js/app.js')
	.addStyleEntry('main', './public/assets/css/main.scss')
	.addStyleEntry('panel', './public/assets/css/panel.scss')

	// ----------------------------------------------------------------------------
	// FEATURES
	// ----------------------------------------------------------------------------

	.disableSingleRuntimeChunk()
	.cleanupOutputBeforeBuild()
	.enableBuildNotifications()
	.enableSourceMaps(!Encore.isProduction())
	.configureBabel((config) => {
		config.plugins.push('@babel/plugin-proposal-class-properties');
	})
	.configureBabelPresetEnv((config) => {
		config.useBuiltIns = 'usage';
		config.corejs = 3;
	})
	.enableSassLoader()
	.enablePostCssLoader()
;

module.exports = Encore.getWebpackConfig();
