checkout/config/webpack.prod.js

54 lines
2.0 KiB
JavaScript
Raw Normal View History

2017-05-02 14:04:52 +00:00
const webpack = require('webpack');
const merge = require('webpack-merge');
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
2018-05-08 12:23:26 +00:00
const CompressionPlugin = require('compression-webpack-plugin');
const checkoutConfig = require('./checkout-config');
const initializerConfig = require('./initializer-config');
const samsungPayConfig = require('./samsung-pay-config');
const prepareOutputConfig = require('./prepare-output-config');
const commonConfig = require('./common-config');
2021-10-01 11:18:36 +00:00
const SentryWebpackPlugin = require('@sentry/webpack-plugin');
2017-05-02 14:04:52 +00:00
const commonProdConfig = {
2017-05-02 14:04:52 +00:00
plugins: [
2018-02-22 11:15:13 +00:00
new webpack.optimize.ModuleConcatenationPlugin(),
2017-05-02 14:04:52 +00:00
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: JSON.stringify('production')
}
}),
new BundleAnalyzerPlugin({
analyzerMode: 'disabled'
2018-05-08 12:23:26 +00:00
}),
new CompressionPlugin({
2018-12-20 08:56:59 +00:00
filename: '[path].gz[query]',
2018-05-08 12:23:26 +00:00
algorithm: 'gzip',
test: /\.js$|\.css$|\.html$|\.json$/,
threshold: 10240,
minRatio: 0.8
2021-10-01 11:18:36 +00:00
}),
...(process.env.SENTRY_AUTH_TOKEN
? [
new SentryWebpackPlugin({
authToken: process.env.SENTRY_AUTH_TOKEN,
2022-01-24 11:38:04 +00:00
org: 'vality',
project: 'checkout',
2021-10-01 11:18:36 +00:00
include: './dist',
ignore: ['node_modules', 'webpack.config.js']
})
]
: [])
2017-05-02 14:04:52 +00:00
]
};
const baseOutput = 'dist';
const prepareModule = (env, baseConfig, outputPath, jsPattern, cssPattern) =>
merge(baseConfig, commonConfig(env), prepareOutputConfig(outputPath, jsPattern, cssPattern), commonProdConfig);
module.exports = (env, { mode }) => [
prepareModule(mode, checkoutConfig, `${baseOutput}/v1`, '[name].[hash:20]', '[hash:20]'),
prepareModule(mode, samsungPayConfig, `${baseOutput}/v1`, '[name].[hash:20]', '[hash:20]'),
prepareModule(mode, initializerConfig, baseOutput)
];