2017-05-02 14:04:52 +00:00
|
|
|
const webpack = require('webpack');
|
|
|
|
const merge = require('webpack-merge');
|
2018-02-15 11:16:12 +00:00
|
|
|
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
|
2018-05-08 12:23:26 +00:00
|
|
|
const CompressionPlugin = require('compression-webpack-plugin');
|
2018-02-16 14:37:17 +00:00
|
|
|
const checkoutConfig = require('./checkout-config');
|
|
|
|
const initializerConfig = require('./initializer-config');
|
2018-08-01 17:11:02 +00:00
|
|
|
const samsungPayConfig = require('./samsung-pay-config');
|
2018-02-15 11:16:12 +00:00
|
|
|
const prepareOutputConfig = require('./prepare-output-config');
|
2019-01-29 16:54:37 +00:00
|
|
|
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
|
|
|
|
2018-02-15 11:16:12 +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')
|
|
|
|
}
|
2018-02-15 11:16:12 +00:00
|
|
|
}),
|
|
|
|
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
|
|
|
]
|
2018-02-15 11:16:12 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
const baseOutput = 'dist';
|
|
|
|
|
2019-01-29 16:54:37 +00:00
|
|
|
const prepareModule = (env, baseConfig, outputPath, jsPattern, cssPattern) =>
|
|
|
|
merge(baseConfig, commonConfig(env), prepareOutputConfig(outputPath, jsPattern, cssPattern), commonProdConfig);
|
2018-02-15 11:16:12 +00:00
|
|
|
|
2019-01-29 16:54:37 +00:00
|
|
|
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)
|
2018-02-15 11:16:12 +00:00
|
|
|
];
|