-
Notifications
You must be signed in to change notification settings - Fork 1
/
webpack.config.js
47 lines (43 loc) · 1.24 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 webpack = require('webpack');
const mode = require('yargs').argv.mode;
const libraryTarget = require('yargs').argv['output-library-target'];
const pkg = require('./package.json');
const libraryName = pkg.name;
const banner = `
${libraryName}
${pkg.description}\n
@version v${pkg.version}
@homepage ${pkg.homepage}
@repository ${pkg.repository.url}\n
(c) 2019 Array-Huang
Released under the MIT License.
hash: [hash]
`;
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: 'MicroSchemaValidator',
libraryTarget: libraryTarget || 'umd',
globalObject: "(typeof self !== 'undefined' ? self : this)", // 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
};