-
Notifications
You must be signed in to change notification settings - Fork 1
/
webpack.config.js
45 lines (41 loc) · 1.33 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
const webpack = require('webpack');
const mode = require('yargs').argv.mode;
const libraryTarget = require('yargs').argv['output-library-target'];
const pkg = require('./package.json');
const libraryName = 'ShapeBuilder';
const banner = `${pkg.name}
${pkg.description}\n
@version v${pkg.version}
@author ${pkg.author}
@homepage ${pkg.homepage}
@repository ${pkg.repository.url}`;
const plugins = [
new webpack.BannerPlugin(banner)
];
module.exports = {
entry: `${__dirname}/index.js`,
devtool: 'source-map',
output: {
path: `${__dirname}/${libraryTarget === 'umd' ? 'dist' : 'lib'}`,
filename: mode === 'development' ? `${libraryName}.js` : `${libraryName}.min.js`,
library: libraryName,
libraryTarget: libraryTarget || 'umd',
globalObject: '(typeof self !== \'undefined\' ? self : this)', // TODO Hack (for Webpack 4+) to enable create UMD build which can be required by Node without throwing error for window being undefined (https://github.com/webpack/webpack/issues/6522)
umdNamedDefine: true
},
module: {
rules: [
{
test: /(\.jsx|\.js)$/,
loader: 'babel-loader',
exclude: /(node_modules|bower_components)/
},
{
test: /(\.jsx|\.js)$/,
loader: 'eslint-loader',
exclude: /(node_modules|bower_components)/
}
]
},
plugins: plugins
};