forked from Authress-Engineering/openapi-resolver.js
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbrowser.config.babel.js
More file actions
106 lines (101 loc) · 2.45 KB
/
browser.config.babel.js
File metadata and controls
106 lines (101 loc) · 2.45 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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
import path from 'path';
import webpack from 'webpack';
import { StatsWriterPlugin } from 'webpack-stats-plugin';
import { DuplicatesPlugin } from 'inspectpack/plugin';
import { WebpackBundleSizeAnalyzerPlugin } from 'webpack-bundle-size-analyzer';
import TerserPlugin from 'terser-webpack-plugin';
import { cloneDeep } from 'lodash';
const module = {
rules: [
{
test: /\.js$/,
// exclude: /node_modules\//,
use: {
loader: 'babel-loader',
},
},
],
};
const browser = {
mode: 'production',
entry: {
main: './src/index.js',
},
target: 'web',
performance: {
hints: false,
},
output: {
path: path.resolve('./dist'),
filename: 'openapi-resolver.browser.js',
library: {
name: 'OpenApiResolver',
type: 'umd',
export: 'default',
},
globalObject: 'this',
},
resolve: {
modules: ['node_modules'],
extensions: ['.js', '.json'],
fallback: {
url: require.resolve('url'),
http: require.resolve('stream-http'),
https: require.resolve('https-browserify'),
buffer: require.resolve('buffer'),
path: require.resolve('path-browserify'),
},
},
module,
plugins: [
new webpack.ProvidePlugin({ Buffer: ['buffer', 'Buffer'] }),
new webpack.LoaderOptionsPlugin({
minimize: true,
}),
new DuplicatesPlugin({
// emit compilation warning or error? (Default: `false`)
emitErrors: true,
// display full duplicates information? (Default: `false`)
verbose: true,
}),
new WebpackBundleSizeAnalyzerPlugin('openapi-resolver.browser-sizes.txt'),
new StatsWriterPlugin({
filename: path.join('openapi-resolver.browser-stats.json'),
fields: null,
}),
],
optimization: {
minimize: false,
usedExports: false,
concatenateModules: false,
},
};
const browserMin = cloneDeep(browser);
browserMin.devtool = 'source-map';
browserMin.performance = {
hints: 'error',
maxEntrypointSize: 310000,
maxAssetSize: 1300000,
};
browserMin.output.filename = 'openapi-resolver.browser.min.js';
browserMin.plugins = [
new webpack.ProvidePlugin({ Buffer: ['buffer', 'Buffer'] }),
new webpack.LoaderOptionsPlugin({
minimize: true,
}),
];
browserMin.optimization = {
minimizer: [
new TerserPlugin({
terserOptions: {
compress: {
warnings: false,
},
output: {
comments: false,
},
},
}),
],
};
export default [browser, browserMin];