Repository navigation
Expand file tree
/
Copy pathwebpack.config.js
More file actions
79 lines (78 loc) · 2.34 KB
/
Copy pathwebpack.config.js
File metadata and controls
79 lines (78 loc) · 2.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
const path = require('path');
const CopyPlugin = require('copy-webpack-plugin');
const TerserPlugin = require('terser-webpack-plugin');
const JavaScriptObfuscator = require('webpack-obfuscator');
const nodeExternals = require('webpack-node-externals');
module.exports = {
target: 'node', // Ensures that Webpack bundles for a Node.js environment
entry: './src/server.js', // Entry point of your application
output: {
path: path.resolve(__dirname, 'dist'), // Output directory
filename: 'nanoTrack.js' // Output file
},
module: {
rules: [
{
test: /\.js$/, // Transpile all .js files
exclude: /node_modules/, // Exclude the node_modules directory
use: {
loader: 'babel-loader', // Use babel-loader for transpiling
options: {
presets: ['@babel/preset-env'] // Preset for compiling ES6 and above into ES5
}
}
}
]
},
resolve: {
extensions: ['.js'], // Automatically resolve these extensions
fallback: {
"mongodb-client-encryption": false ,
"aws4": false
}
},
externals: [nodeExternals()],
optimization: {
minimize: true,
minimizer: [
new TerserPlugin({
terserOptions: {
compress: {
drop_console: true, // Removes console logs for production
drop_debugger: true,
pure_funcs: ['console.info', 'console.debug', 'console.warn'],
// Additional compression options can be added here
},
mangle: {
// Mangle options go here
// properties: {
// // Mangle property options (be cautious with this)
// },
},
format: {
comments: false, // Remove comments
},
// Additional Terser options can be added here
},
extractComments: false,
}),
],
},
plugins: [
new CopyPlugin({
patterns: [
{ from: 'src/ui', to: 'ui' } // Adjust the paths as necessary
],
}),
new JavaScriptObfuscator({
// Options for obfuscation
// See https://github.com/javascript-obfuscator/javascript-obfuscator#options
rotateStringArray: true,
stringArray: true,
stringArrayThreshold: 0.75,
disableConsoleOutput: true,
renameGlobals: true,
// renameProperties: true,
}, []),
],
};