generated from junyux/lib-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
42 lines (38 loc) · 927 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
const path = require('path');
const packageConfig = require('./package.json');
function getPackageName (str) {
return str.replace(/^@\w+\//g, '');
}
function toCamelCase (str) {
return str.replace(/-([a-z])/ig, (s, p1) => p1.toUpperCase());
}
const packageName = getPackageName(packageConfig.name);
const libraryName = toCamelCase(packageName);
module.exports = function (env = {}) {
return {
mode: env.mode,
entry: './src/index.js',
output: {
path: path.resolve(__dirname, 'dist'),
filename: `${packageName}.js`,
library: libraryName,
libraryTarget: 'umd'
},
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules\/.*/,
use: {
loader: 'babel-loader'
}
}
]
},
devServer: {
contentBase: path.join(__dirname, env.server || '.'),
port: 9090,
hot: true
}
};
};