-
Notifications
You must be signed in to change notification settings - Fork 5
/
webpack.config.js
38 lines (36 loc) · 904 Bytes
/
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
const path = require('path');
const webpack = require('webpack');
const TerserPlugin = require('terser-webpack-plugin');
module.exports = {
entry: './index.js',
mode: 'production',
output: {
filename: '[name].min.js',
path: path.resolve(__dirname, 'dist'),
libraryTarget: 'umd', // Generate UMD bundle
globalObject: 'this', // This line ensures `this` is used as the global object
},
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader',
options: {
presets: ['@babel/preset-env'],
},
},
},
],
},
optimization: {
minimizer: [new TerserPlugin()], // Add TerserPlugin for minification
},
plugins: [
new webpack.DefinePlugin({
// Define 'self' as 'global' for non-browser environments
'self': 'global',
}),
],
};