const WrmPlugin = require('atlassian-webresource-webpack-plugin');
const path = require('path');
const webpack = require('webpack');
const TerserPlugin = require('terser-webpack-plugin');
// const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
module.exports = {
mode: 'production',
module: {
rules: [
{
test: /\.tsx?$/,
use: {
loader: 'babel-loader',
options: {
presets: ['@babel/preset-env'],
},
},
exclude: /node_modules/,
},
{
test: /\.css$/,
use: ['style-loader', 'css-loader'],
},
],
},
watch: true,
entry: {
app: './src/App.tsx',
},
resolve: {
extensions: ['.tsx', '.ts', '.js'],
fallback: {
"buffer": require.resolve('buffer/'),
}
},
plugins: [
new WrmPlugin({
pluginKey: '#',
locationPrefix: 'frontend/',
contextMap: {
app: ['app'],
},
watch: true,
xmlDescriptors: path.resolve('../backend/src/main/resources', 'META-INF', 'plugin-descriptors', 'wr-defs.xml'),
}),
new webpack.ProvidePlugin({
Buffer: ['buffer', 'Buffer'],
}),
new webpack.ProvidePlugin({
process: 'process/browser',
}),
new webpack.optimize.LimitChunkCountPlugin({
maxChunks: 1
}),
// new BundleAnalyzerPlugin(),
],
optimization: {
mangleExports: 'size',
mangleWasmImports: true,
minimize: true,
minimizer: [new TerserPlugin({
exclude: /node_modules/,
minify: TerserPlugin.swcMinify,
parallel: true,
terserOptions: {
compress: true,
mangle: true,
toplevel: true,
module: true,
keep_classnames: false,
keep_fnames: false,
}
})],
nodeEnv: 'production',
removeAvailableModules: true,
innerGraph: true,
usedExports: true
},
output: {
filename: 'bundled.[name].js',
path: path.resolve('../backend/src/main/resources/frontend')
},
}