const path = require('path')
const Timestamp = new Date().getTime();

function resolve(dir) {
	return path.join(__dirname, './', dir)
}

module.exports = {
	outputDir: '../wwwroot',
	//lintOnSave: process.env.NODE_ENV !== 'production',
	lintOnSave: false,
	pages: {
		app: {
			entry: 'src/main.js',
			template: 'public/index.html',
			filename: 'index.html',
			excludeChunks: ['silent-renew-oidc']
		},
		silentrenewoidc: {
			entry: 'src/silent-renew-oidc.js',
			template: 'public/silent-renew-oidc.html',
			filename: 'silent-renew-oidc.html',
			excludeChunks: ['app']
		}
	},
	chainWebpack(config) {
		config.module
			.rule('svg')
			.exclude
			.add(resolve('src/icons/svg'))
			.add(resolve('src/assets/student-web/icons'))
			.end()
		config.module
			.rule('icons')
			.test(/\.svg$/)
			.include
			.add(resolve('src/icons/svg'))
			.add(resolve('src/assets/student-web/icons'))
			.end()
			.use('svg-sprite-loader')
			.loader('svg-sprite-loader')
			.options({
				symbolId: 'icon-[name]'
			})
			.end()
	},
	pluginOptions: {
		'style-resources-loader': {
			preProcessor: 'less',
			patterns: [
				// 这个是加上自己的路径,不能使用(如下:alias)中配置的别名路径
				path.resolve(__dirname, './src/css/less-variable.less')
			]
		}
	},
	configureWebpack: config => {
		config.optimization.minimizer[0].options.terserOptions.compress.drop_console = process.env.NODE_ENV ===
			'production'
		config.entry.app = ["babel-polyfill", "./src/main.js"];
	},
	configureWebpack: {
		output: { // 输出重构  打包编译后的 文件名称  【模块名称.版本号.js】
			filename: `js/[name].${Timestamp}.js`,
			chunkFilename: `js/[name].${Timestamp}.js`
			// chunkFilename: `js/[id].vw.js`
		}
	}
}
