const { defineConfig } = require('@vue/cli-service')
const webpack = require('webpack');

const path = require('path')

function resolve(dir) {
	return path.join(__dirname, dir)
}
module.exports = defineConfig({
	transpileDependencies: true,
	publicPath: process.env.NODE_ENV === 'production' ? "https://ansnid.oss-cn-shenzhen.aliyuncs.com/forum" : '/',
	// publicPath: "https://x-cloud-project.oss-cn-guangzhou.aliyuncs.com/forum",
	configureWebpack: {
		optimization: {
			splitChunks: {
				chunks: 'all',
				minSize: 20000,
				maxSize: 50000,
				minChunks: 1,
				maxAsyncRequests: 30,
				maxInitialRequests: 30,
				automaticNameDelimiter: '~',
				enforceSizeThreshold: 50000,
				cacheGroups: {
					vendors: {
						test: /[\\/]node_modules[\\/]/,
						priority: -10,
						filename: 'js/chunk-vendors.[contenthash].js',
					},
				},
			},
		},

		resolve: {
			alias: {
				'assets': '@/assets',
				'common': '@/common',
				'components': '@/components',
				'network': '@/network',
				'views': '@/views'
			}
		},
		// plugins: [
		// new BundleAnalyzerPl/ugin(),
		// ],
	},
	// svg图片配置
	lintOnSave: false,
	chainWebpack(config) {
		config.module
			.rule('svg')
			.exclude.add(resolve('src/icons'))       //svg的存储地址
			.end()
		config.module
			.rule('icons')
			.test(/\.svg$/)
			.include.add(resolve('src/icons'))        //svg的存储地址
			.end()
			.use('svg-sprite-loader')
			.loader('svg-sprite-loader')
			.options({
				symbolId: 'icon-[name]'
			})
			.end()

	},
	productionSourceMap: false,
})
