
const path = require('path');

const CompressionWebpackPlugin = require("compression-webpack-plugin")
const productionGzipExtensions = ['js', 'css']

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

let title = '';
if (process.env.VUE_APP_NODE_NAME == 'production') {
	title = ''
} else if (process.env.VUE_APP_NODE_NAME == 'test') {
	title = '(测试)'
} else {
	title = '(开发)'
}

const Timestamp = new Date().getTime();
const config = {
	//商业园区
	business: {
		pages: {
			index: {
				entry: 'src/projects/business/main.js',
				template: 'index/business/index.html',
				filename: 'index.html',
				title: '湖北新生源生物工程有限公司' + title,
			}
		},
		outputDir: 'dist',
		devServer: {
			host: '0.0.0.0',
			port: 8080,
		},
		chainWebpack: (config) => {
			config.entry.app = ['babel-polyfill', '../src/projects/business/main.js']
			config.resolve.alias
				.set('@', resolve('../src/projects/business/'))
				.set('$project', resolve('../src/'))
				.set('$root', resolve('../'))

			config.plugins.delete('preload-index');
			config.plugins.delete('prefetch-index');

			config.optimization.minimize(true);

			//打包分析添加
			//config.output.filename('js/[name].[hash].js').end();
			//config.plugin('webpack-bundle-analyzer').use(require('webpack-bundle-analyzer').BundleAnalyzerPlugin)
		},
		configureWebpack: config => {
			

			config.output.filename = `./static/js/[name].${Timestamp}.js?v=${Timestamp}`
			config.output.chunkFilename = `./static/js/[name].${Timestamp}.js?v=${Timestamp}`

		},
	}

}

const configObj = config["business"]
module.exports = configObj
