Skip to content

Commit

Permalink
chore: optimized webpack config + added terser to minimize bundle size
Browse files Browse the repository at this point in the history
  • Loading branch information
kenso312 committed Oct 22, 2022
1 parent 57b17e9 commit 73f9a58
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 13 deletions.
4 changes: 0 additions & 4 deletions tsconfig.build.json

This file was deleted.

41 changes: 32 additions & 9 deletions webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,38 @@
/* eslint-disable @typescript-eslint/no-var-requires */
const path = require('path');
const { IgnorePlugin } = require('webpack');
const TsconfigPathsPlugin = require('tsconfig-paths-webpack-plugin');
const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');
const TerserPlugin = require('terser-webpack-plugin');
const TsconfigPathsPlugin = require('tsconfig-paths-webpack-plugin');

const tsConfigFile = 'tsconfig.json';

module.exports = {
entry: path.resolve('src', 'main'),
target: 'node',
entry: './src/main',
externals: {},
module: { rules: [{ test: /\.ts$/, loader: 'ts-loader' }] },
module: {
rules: [{ test: /\.ts$/, loader: 'ts-loader' }],
},
node: {
__filename: false,
__dirname: false,
},
optimization: {
nodeEnv: false,
minimize: true,
minimizer: [
new TerserPlugin({
terserOptions: {
keep_classnames: true,
keep_fnames: true,
},
}),
],
},
output: {
path: path.resolve(__dirname, 'dist'),
path: path.resolve(__dirname, 'dist/'),
filename: '[name].js',
},
resolve: {
extensions: ['.js', '.json', '.ts'],
plugins: [new TsconfigPathsPlugin()],
},
plugins: [
new IgnorePlugin({
checkResource(resource) {
Expand All @@ -30,6 +46,7 @@ module.exports = {
'amqp-connection-manager',
'amqplib',
'cache-manager',
'cache-manager/package.json',
'class-transformer/storage',
'hbs',
'ioredis',
Expand All @@ -50,4 +67,10 @@ module.exports = {
}),
new ForkTsCheckerWebpackPlugin(),
],
resolve: {
extensions: ['.js', '.json', '.ts'],
mainFields: ['main'],
plugins: [new TsconfigPathsPlugin({ configFile: tsConfigFile })],
},
target: 'node',
};

0 comments on commit 73f9a58

Please sign in to comment.