forked from juspay/presto-ui
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.common.js
71 lines (64 loc) · 1.68 KB
/
webpack.common.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
const path = require('path')
const webpack = require('webpack');
const WebpackBar = require('webpackbar');
const DashboardPlugin = require("webpack-dashboard/plugin");
const WebpackBuildNotifierPlugin = require('webpack-build-notifier');
const packageJSON = require("./package.json");
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
const isWebpackDevServer = process.argv.some(a => path.basename(a) === 'serve');
const isWatch = process.argv.includes('--watch');
const isAnalyse = process.argv.includes('--analyse');
__VERSION__ = packageJSON.version
var plugins = [
new WebpackBar(),
new webpack.DefinePlugin({
// Set this to false to create a build that contains DateRangePicker for web
'__ignoreDateRangePickerWeb': JSON.stringify(true),
__VERSION__: JSON.stringify(packageJSON.version)
}),
];
if (isWatch || isWebpackDevServer) {
plugins.push(
new DashboardPlugin(),
new WebpackBuildNotifierPlugin({
title: "PrestoUI",
})
)
}
if (isAnalyse) {
plugins.push(
new BundleAnalyzerPlugin()
)
}
let config = {
devtool: "source-map",
output: {
path: path.join(__dirname,"/lib"),
filename: "index.js",
libraryTarget: 'commonjs2',
environment: {
arrowFunction: false,
bigIntLiteral: false,
const: false,
destructuring: false,
dynamicImport: false,
forOf: false,
module: false
},
},
module: {
rules: [
{ test: /\.js$/,
exclude: /node_modules/,
use: {
loader: "babel-loader",
options: {
presets: ["@babel/preset-env"],
}
}
},
]
},
plugins: plugins
}
module.exports = config