-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathwebpack.config.js
90 lines (84 loc) · 2.82 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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
/*
* @copyright (c) 2017, 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 WebpackBuildNotifier = require('webpack-build-notifier');
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();
const outputFilename = minify ? 'js-joda-locale.min.js' : 'js-joda-locale.js';
const createConfig = (/*env, argv*/) => {
const config = {
mode: minify ? 'production' : 'development',
context: __dirname,
entry: './src/js-joda-locale.js',
devtool: sourceMaps ? 'hidden-source-map' : false,
output: {
globalObject: 'this',
path: `${__dirname}/dist`,
filename: outputFilename,
libraryTarget: 'umd',
library: 'JSJodaLocale',
},
externals: {
'js-joda': {
amd: 'js-joda',
commonjs: 'js-joda',
commonjs2: 'js-joda',
root: 'JSJoda',
},
'js-joda-timezone': {
amd: 'js-joda-timezone',
commonjs: 'js-joda-timzezone',
commonjs2: 'js-joda-timezone',
root: 'JSJodaTimezone',
},
'cldr-data': {
amd: 'cldr-data',
commonjs: 'cldr-data',
commonjs2: 'cldr-data',
root: 'cldrData',
},
'cldrjs': {
amd: 'cldrjs',
commonjs: 'cldrjs',
commonjs2: 'cldrjs',
root: 'Cldr',
},
},
module: {
rules: [
{
use: [{ loader: 'babel-loader' }],
resource: {
include: [
path.resolve(__dirname, 'src'),
path.resolve(__dirname, 'test'),
],
test: /.js$/,
}
},
],
},
plugins: [
new webpack.BannerPlugin({ banner, raw: true }),
new WebpackBuildNotifier(),
],
performance: {
/* we know that we will be generating big packages with locale data, no reason to have webpack warn us */
maxEntrypointSize: 25000000,
maxAssetSize: 25000000,
}
};
return config;
};
module.exports = createConfig;