-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
62 lines (61 loc) · 1.84 KB
/
webpack.config.js
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
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const TerserPlugin = require('terser-webpack-plugin');
const CssMinimizerPlugin = require('css-minimizer-webpack-plugin');
const Obfuscator = require('webpack-obfuscator');
module.exports = {
entry: './src/index.js', // Path to your main JavaScript file
output: {
path: path.resolve(__dirname, 'dist'), // Output directory
filename: 'bundle.js' // Output filename
},
module: {
rules: [
{
test: /\.css$/, // Match CSS files
use: ['style-loader', 'css-loader'] // Loaders to handle CSS files
}
]
},
optimization: {
minimize: true,
minimizer: [
new TerserPlugin({
terserOptions: {
format: {
comments: false, // Remove comments
},
compress: {
drop_console: true // Remove console.log statements
},
mangle: true // Obfuscate variable and function names
}
}),
new CssMinimizerPlugin({
minimizerOptions: {
preset: ['default', { discardComments: { removeAll: true } }]
}
})
]
},
plugins: [
new HtmlWebpackPlugin({
template: './src/index.html', // Path to your HTML template file
minify: {
removeComments: true, // Remove HTML comments
collapseBooleanAttributes: true, // Collapse boolean attributes
collapseWhitespace: true, // Collapse white space
removeAttributeQuotes: true, // Remove attribute quotes
minifyCSS: true, // Minify CSS
minifyJS: true // Minify JS
}
}),
new Obfuscator({
rotateStringArray: true,
stringArray: true,
selfDefending: true,
deadCodeInjection: true,
unicodeEscapeSequence: true,
})
]
};