Skip to content

Instantly share code, notes, and snippets.

@anechunaev
Created August 29, 2023 17:36
Show Gist options
  • Save anechunaev/95e077e36d13d53fd9fb473c2f1f56cf to your computer and use it in GitHub Desktop.
Save anechunaev/95e077e36d13d53fd9fb473c2f1f56cf to your computer and use it in GitHub Desktop.
Webpack configuration for a fast build
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