-
Notifications
You must be signed in to change notification settings - Fork 81
/
webpack.config.js
97 lines (92 loc) · 2.24 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
91
92
93
94
95
96
97
const webpack = require('webpack');
const path = require('path');
const fs = require('fs');
const EsmWebpackPlugin = require('@purtuga/esm-webpack-plugin');
const merge = require('lodash.merge');
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
const WebpackAssetsManifest = require('webpack-assets-manifest');
const banner = fs.readFileSync('./LICENSE', 'utf8').replace('{year}', new Date().getFullYear());
const config = {
mode: 'production',
node: {
Buffer: false,
fs: 'empty',
},
watchOptions: {
ignored: /node_modules/
},
entry: './build/module/index.js',
output: {
libraryTarget: 'umd',
library: 'filestack',
path: path.resolve(__dirname, 'build/browser'),
filename: 'filestack.umd.js',
},
module: {
rules: [
{
test: /\.(js|jsx)$/,
exclude: /^.*\.node\.js|.*\.node\.spec\.js|.*\.browser\.spec\.js|.*\.spec\.js$/,
use: {
loader: 'babel-loader',
options: {
presets: [
[
'@babel/preset-env',
{
targets: '> 0.25%, not dead, ie 11',
},
],
],
},
},
},
],
},
performance: {
maxEntrypointSize: 255000,
maxAssetSize: 255000
},
plugins: [
new CleanWebpackPlugin(),
new webpack.BannerPlugin({ banner }),
new webpack.DefinePlugin({
'process.env.NODE_ENV': 'production',
'@{VERSION}' : `${require('./package.json').version}`,
}),
new webpack.NormalModuleReplacementPlugin(/^.*\.node\.js$/, (result) => {
if (result.resource) {
result.resource = result.resource.replace(/node/g, 'browser');
}
}),
],
devtool: 'source-map',
};
const umd = merge({}, config, {
output: {
libraryTarget: 'umd',
filename: 'filestack.umd.js',
},
});
const esm = merge({}, config, {
output: {
libraryTarget: 'var',
filename: 'filestack.esm.js',
},
plugins: [
new EsmWebpackPlugin(),
]
});
const prod = merge({}, config, {
output: {
libraryTarget: 'umd',
filename: 'filestack.min.js',
},
plugins: [
new WebpackAssetsManifest({
writeToDisk: true,
integrity: true,
}),
],
});
module.exports = { umd, esm, prod };