Created
August 29, 2023 17:36
-
-
Save anechunaev/95e077e36d13d53fd9fb473c2f1f56cf to your computer and use it in GitHub Desktop.
Webpack configuration for a fast build
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const path = require('path'); | |
const TerserPlugin = require("terser-webpack-plugin"); | |
module.exports = { | |
target: 'node14', | |
entry: './src/index.ts', | |
output: { | |
path: path.resolve(__dirname, 'dist'), | |
filename: 'index.js', | |
libraryTarget: 'commonjs2', | |
strictModuleExceptionHandling: true, | |
}, | |
resolve: { | |
alias: { | |
}, | |
extensions: ['.js', '.ts', '.mjs', '.json'], | |
}, | |
module: { | |
rules: [ | |
{ | |
test: /\.m?(j|t)s$/, | |
exclude: /node_modules/i, | |
use: { | |
loader: "swc-loader", | |
}, | |
}, | |
], | |
}, | |
mode: 'production', | |
plugins: [ | |
], | |
optimization: { | |
nodeEnv: false, | |
minimize: true, | |
minimizer: [new TerserPlugin({ | |
parallel: true, | |
minify: TerserPlugin.swcMinify, | |
terserOptions: { | |
format: { | |
comments: false, | |
}, | |
}, | |
extractComments: false, | |
})], | |
moduleIds: 'deterministic', | |
chunkIds: 'deterministic', | |
mangleExports: true, | |
concatenateModules: true, | |
innerGraph: true, | |
sideEffects: true | |
}, | |
stats: { | |
logging: 'error' | |
}, | |
infrastructureLogging: { | |
level: 'error' | |
}, | |
node: false, | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment