-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathwebpack.config.js
68 lines (64 loc) · 1.83 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
/*
* @copyright (c) 2016, Philipp Thuerwaechter & Pattrick Hueper
* @license BSD-3-Clause (see LICENSE.md in the root directory of this source tree)
*/
const fs = require('fs');
const path = require('path');
const webpack = require('webpack');
const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
const minify = JSON.parse(process.env.DIST_MIN || '0');
const sourceMaps = !minify;
function createBanner() {
const packageJson = require('./package.json');
const version = `//! @version ${packageJson.name} - ${packageJson.version}\n`;
const preamble = fs.readFileSync('./src/license-preamble.js', 'utf8');
return version + preamble;
}
const banner = createBanner();
module.exports = {
mode: minify ? 'production' : 'development',
context: __dirname,
entry: './src/js-joda-extra.js',
devtool: sourceMaps ? 'hidden-source-map' : false,
output: {
path: `${__dirname}/dist`,
filename: minify ? 'js-joda-extra.min.js' : '[name].js',
libraryTarget: 'umd',
library: 'JSJodaExtra',
globalObject: 'this',
},
externals: {
'js-joda': {
amd: 'js-joda',
commonjs: 'js-joda',
commonjs2: 'js-joda',
root: 'JSJoda',
},
},
module: {
rules: [{
use: 'babel-loader',
include: [
path.resolve(__dirname, 'src'),
path.resolve(__dirname, 'test'),
],
test: /.js$/,
}],
},
optimization: {
minimizer: [
new UglifyJsPlugin({
uglifyOptions: {
output: {
comments: /^!/,
},
}
})
]
},
plugins: [
new webpack.BannerPlugin(
{banner: banner, raw: true}
)
],
};