This repository was archived by the owner on Feb 17, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathwebpack.config.js
More file actions
66 lines (64 loc) · 1.92 KB
/
webpack.config.js
File metadata and controls
66 lines (64 loc) · 1.92 KB
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
const path = require('path');
const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const pkg = require('./package.json');
const mode = process.env.NODE_ENV || 'development';
const prod = mode === 'production';
const devserver = process.env.DEV_SERVER || false;
module.exports = {
mode,
context: path.resolve(__dirname, 'src'),
entry: [
'./index.js',
devserver ? './test.js' : false,
].filter(Boolean),
output: {
path: path.resolve(__dirname, 'dist'),
filename: prod ? 'iro-transparency-plugin.min.js' : 'iro-transparency-plugin.js',
library: 'iroTransparencyPlugin',
libraryExport: 'default',
libraryTarget: 'umd',
umdNamedDefine: true,
// for some reason webpack 4's umd implementation uses window as a global object
// this means that these modules won't work in node js environments unless you manually change this
// see https://github.com/webpack/webpack/issues/6522#issuecomment-371120689
globalObject: "typeof self !== 'undefined' ? self : this",
},
module: {
rules: [
{
test: /\.jsx?$/,
exclude: /(node_modules|bower_components)/,
use: {
loader: 'babel-loader',
options: {
presets: [
'@babel/preset-env',
],
plugins: [
['@babel/plugin-transform-react-jsx', {pragma: 'h'}]
]
}
}
}
]
},
plugins: [
new webpack.BannerPlugin({
banner: [
'iro-transparency-plugin v' + pkg.version,
pkg.description,
'2019 James Daniel',
'Licensed under MPL 2.0',
'github.com/jaames/iro-transparency-plugin',
].join('\n')
}),
new webpack.DefinePlugin({
VERSION: JSON.stringify(pkg.version),
IS_PROD: prod,
IS_DEV_SERVER: devserver,
}),
devserver ? new HtmlWebpackPlugin() : false
].filter(Boolean),
devtool: 'source-map',
};