const path = require('path')
const webpack = require('webpack')
const { VueLoaderPlugin } = require('vue-loader')

module.exports = {
	entry: {
		'mitgliederverwaltung-main': path.join(__dirname, 'src', 'main.js'),
	},
	output: {
		path: path.resolve(__dirname, 'js'),
		publicPath: '/custom_apps/mitgliederverwaltung/js/',
		filename: '[name]-[contenthash].js',
		chunkFilename: '[name]-[contenthash].js',
	},
	module: {
		rules: [
			{
				test: /\.vue$/,
				loader: 'vue-loader',
			},
			{
				test: /\.js$/,
				loader: 'babel-loader',
				exclude: /node_modules/,
			},
			{
				test: /\.css$/,
				use: ['style-loader', 'css-loader'],
			},
			{
				test: /\.scss$/,
				use: ['style-loader', 'css-loader', 'sass-loader'],
			},
			{
				test: /\.(png|jpe?g|gif|svg|woff2?|eot|ttf|otf)$/,
				type: 'asset/resource',
			},
		],
	},
	plugins: [
		new VueLoaderPlugin(),
		new webpack.DefinePlugin({
			appName: JSON.stringify('mitgliederverwaltung'),
			appVersion: JSON.stringify('0.3.2'),
		}),
		new webpack.optimize.LimitChunkCountPlugin({
			maxChunks: 1,
		}),
	],
	optimization: {
		splitChunks: false,
	},
	resolve: {
		extensions: ['.js', '.vue'],
		alias: {
			vue$: 'vue/dist/vue.esm-bundler.js',
		},
	},
}
