-
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathwebpack.config.js
47 lines (46 loc) · 1.41 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
const path = require('path');
const TerserPlugin = require('terser-webpack-plugin');
module.exports = {
mode: 'production', // or 'development'
entry: './src/index.js', // Entry point of your application
output: {
path: path.resolve(__dirname, '../if-follow-package', 'lib'), // Output directory
filename: 'index.js', // Output filename
library: 'ifFollow', // Name of your library
libraryTarget: 'umd', // Universal Module Definition
// Expose the default export as a global variable
globalObject: 'this',
},
optimization: {
minimize: true, // or false if you want to disable minification
minimizer: [
new TerserPlugin({
terserOptions: {
keep_fnames: true, // Preserve function names
},
}),
],
},
module: {
rules: [
{
test: /\.js$/, // Apply Babel only to JavaScript files
exclude: /node_modules/, // Exclude node_modules directory
use: {
loader: 'babel-loader', // Use babel-loader for transpilation
options: {
presets: ['@babel/preset-env'], // Use @babel/preset-env for compatibility
plugins: [
// Exclude arrow function transformation
['@babel/plugin-transform-arrow-functions', { spec: true }],
],
},
},
},
],
},
// Add this to see any webpack-related errors
stats: {
colors: true,
},
};