-
-
Notifications
You must be signed in to change notification settings - Fork 184
/
Copy pathwebpack.config.js
43 lines (37 loc) · 875 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
39
40
41
42
43
const path = require('path')
const { CleanWebpackPlugin } = require('clean-webpack-plugin')
const packageJson = require('./package.json')
const DASH = /-([a-z])/g
function getLibraryName(str) {
return (
str.charAt(0).toUpperCase() +
str.substr(1).replace(DASH, (match) => match[1].toUpperCase())
)
}
module.exports = {
mode: 'production',
entry: './index',
context: path.resolve(__dirname, './src'),
output: {
filename: 'index.js',
libraryTarget: 'umd',
umdNamedDefine: true,
path: path.resolve(__dirname, './umd'),
library: getLibraryName(packageJson.name),
},
resolve: {
extensions: ['.json', '.js'],
},
module: {
rules: [
{
test: /\.m?js$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader',
},
},
],
},
plugins: [new CleanWebpackPlugin()],
}