-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathwebpack.config.js
72 lines (60 loc) · 2.36 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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/* eslint-env node, node */
'use strict';
const webpack = require('webpack');
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
const path = require('path');
module.exports = (env, argv) => {
const isDevelopmentMode = argv.mode === 'development';
const config = {
entry: path.join(__dirname, 'src', 'iframily.js'),
output: {
path: path.join(__dirname, 'dist'),
filename: 'iframily.min.js',
library: 'Iframily',
libraryTarget: 'umd',
// NOTE: Important in order for the library to support handling "require()" in node env.
// NOTE: see https://github.com/webpack/webpack/issues/6677
// NOTE: see https://medium.com/@JakeXiao/window-is-undefined-in-umd-library-output-for-webpack4-858af1b881df
// NOTE: see https://webpack.js.org/configuration/output/#outputglobalobject
globalObject: 'this'
},
devtool: isDevelopmentMode ? 'eval' : '',
module: {
rules: [
{
// NOTE: This lints only files bundled by webpack (and not the "tests" folder for example...)
enforce: 'pre',
test: /\.js$/,
exclude: /node_modules/,
loader: 'eslint-loader',
options: {
// Show only errors while developing.
quiet: isDevelopmentMode,
// Fail on warning/errors when not developing.
failOnWarning: !isDevelopmentMode,
failOnError: !isDevelopmentMode
},
},
{
test: /\.js$/,
exclude: path.join(__dirname, 'node_modules'),
use: {
loader: 'babel-loader',
options: {
presets: ['@babel/preset-env']
}
}
}
]
},
plugins: [new CleanWebpackPlugin()]
};
if (isDevelopmentMode) {
config.plugins = config.plugins || [];
// Used for tests to identify development bundle.
config.plugins.push(new webpack.BannerPlugin({
banner: 'DEVELOPMENT BUNDLE'
}));
}
return config;
};