-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathwebpack.config.js
More file actions
28 lines (27 loc) · 872 Bytes
/
webpack.config.js
File metadata and controls
28 lines (27 loc) · 872 Bytes
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
const path = require('path');
module.exports = {
entry: './src/index.js', // Entry point of your component
output: {
path: path.resolve(__dirname, 'dist'), // Output directory
filename: 'index.js', // Output file name
library: 'YourReactComponent', // Global variable name for consuming in browser
libraryTarget: 'umd', // Universal Module Definition
umdNamedDefine: true,
},
module: {
rules: [
{
test: /\.(js|jsx)$/,
exclude: /node_modules/,
use: 'babel-loader', // Use Babel to transpile JavaScript/React code
},
],
},
resolve: {
extensions: ['.js', '.jsx'], // File extensions to resolve
},
externals: {
react: 'react', // Exclude React from the bundle if it's a peer dependency
'react-dom': 'react-dom', // Exclude React DOM from the bundle if it's a peer dependency
},
};