const HtmlWebpackPlugin = require('html-webpack-plugin');
const webpack = require('webpack');
const path = require('path');

const URL = {
	test_local: {
		service_name: 'http://10.3.0.33/insure',
		login_url:
			'https://10.1.13.53:7002/casserver/login?service=http://10.3.0.33/insure',
		logout_url:
			'https://10.1.13.53:7002/casserver/logout?service=http://10.3.0.33/insure',
		root_url: '/api/',
	},
	test_remote: {
		service_name: 'https://safeliab-test.ccic-net.com.cn/api/insure/login/',
		login_url:
			'https://ssotest.ccic-net.com.cn/casserver/login?service=https://safeliab-test.ccic-net.com.cn/api/insure/login/',
		logout_url:
			'https://ssotest.ccic-net.com.cn/casserver/logout?service=https://safeliab-test.ccic-net.com.cn/api/insure/login/',
		root_url: '/api/',
	},
	remote: {
		service_name: 'https://safeliab.ccic-net.com.cn/web/auth/',
		login_url:
			'https://sso.ccic-net.com.cn/casserver/login?service=https://safeliab.ccic-net.com.cn/web/auth/',
		logout_url:
			'https://sso.ccic-net.com.cn/casserver/logout?service=https://safeliab.ccic-net.com.cn/web/auth/',
		root_url: '/web/',
	},
	local: {
		service_name: 'http://safeliab.cloud.ccic-net.com.cn/web/auth/',
		login_url:
			'https://app.ccic-net.com.cn:27051/casserver/login?service=http://safeliab.cloud.ccic-net.com.cn/web/auth/',
		logout_url:
			'https://app.ccic-net.com.cn:27051/casserver/logout?service=http://safeliab.cloud.ccic-net.com.cn/web/auth/',
		root_url: '/web/',
	},
};

module.exports = {
	entry: './index.js',
	mode: 'production',
	output: {
		path: path.resolve(__dirname, '../../target/auth'),
		filename: '[name].[chunkhash:8].js',
		chunkFilename: '[name].[chunkhash:8].js',
	},
	module: {
		rules: [
			{
				test: /\.m?js$/,
				exclude: /(node_modules|bower_components)/,
				use: {
					loader: 'babel-loader',
					options: {
						presets: ['@babel/preset-env'],
					},
				},
			},
		],
	},
	plugins: [
		new HtmlWebpackPlugin({
			title: '大地智慧安全服务平台',
		}),
	],
};