-
Notifications
You must be signed in to change notification settings - Fork 1
/
webpack.config.js
47 lines (44 loc) · 1.23 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 CompressionPlugin = require('compression-webpack-plugin');
const capitalizeString = s => s.charAt(0).toUpperCase() + s.slice(1);
module.exports = env => {
const NODE_ENV = process.env.NODE_ENV;
const mode = NODE_ENV || 'development';
const prod = mode === 'production';
const packageName = process.env.npm_package_name;
const packageNameCapital = packageName
.split('-')
.map(capitalizeString)
.join('');
const packageVersion = JSON.stringify(process.env.npm_package_version).replace(/"/g, '');
const filename = `${packageName}-${packageVersion}${prod ? '.min' : ''}.js`;
return {
mode,
devtool: 'none',
resolve: {
extensions: ['.js', '.ts'],
},
entry: ['./src/index.ts'],
output: {
path: path.join(__dirname, 'build/dist'),
filename,
library: {
root: packageNameCapital,
amd: packageName,
commonjs: packageName,
},
libraryTarget: 'umd',
},
externals: 'lc-form-validation',
module: {
rules: [
{
test: /\.(tsx?)|(js)$/,
exclude: /node_modules/,
loader: 'babel-loader',
},
],
},
plugins: prod ? [new CompressionPlugin()] : [],
};
};