forked from schrodinger/fixed-data-table-2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
116 lines (101 loc) · 2.75 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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
var webpack = require('webpack');
var path = require('path');
var glob = require('glob');
var MiniCssExtractPlugin = require('mini-css-extract-plugin');
var packageJSON = require('./package.json');
const TerserPlugin = require('terser-webpack-plugin');
var isDev = process.env.NODE_ENV !== 'production';
var banner =
'/**\n' +
' * FixedDataTable v' +
packageJSON.version +
' \n' +
' *\n' +
' * Copyright Schrodinger, LLC\n' +
' * All rights reserved.\n' +
' *\n' +
' * This source code is licensed under the BSD-style license found in the\n' +
' * LICENSE file in the root directory of this source tree. An additional grant\n' +
' * of patent rights can be found in the PATENTS file in the same directory.\n' +
' */\n';
var plugins = [
new MiniCssExtractPlugin({
filename: '[name].css',
}),
new webpack.DefinePlugin({
__DEV__: isDev,
}),
];
var entry = {};
var baseEntryPoints = glob.sync(path.join(__dirname, './src/css/layout/*.css'));
var styleEntryPoints = glob.sync(path.join(__dirname, './src/css/style/*.css'));
var mainEntryPoints = glob.sync(path.join(__dirname, './src/**/*.css'));
mainEntryPoints.push('./src/FixedDataTableRoot.js');
if (process.env.COMPRESS) {
entry['fixed-data-table-base.min'] = baseEntryPoints;
entry['fixed-data-table-style.min'] = styleEntryPoints;
entry['fixed-data-table.min'] = mainEntryPoints;
} else {
entry['fixed-data-table-base'] = baseEntryPoints;
entry['fixed-data-table-style'] = styleEntryPoints;
entry['fixed-data-table'] = mainEntryPoints;
}
plugins.push(new webpack.BannerPlugin({ banner, raw: true }));
module.exports = {
mode: isDev ? 'development' : 'production',
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
use: 'babel-loader',
},
{
test: /\.css$/,
use: [
{
loader: MiniCssExtractPlugin.loader,
options: {
// only enable hot in development
hmr: isDev,
fallback: 'style-loader',
},
},
'css-loader',
path.join(__dirname, './build_helpers/cssTransformLoader'),
],
},
],
},
entry: entry,
output: {
library: 'FixedDataTable',
libraryTarget: 'umd',
path: path.resolve(__dirname, 'dist'),
filename: '[name].js',
},
externals: {
react: {
root: 'React',
commonjs: 'react',
commonjs2: 'react',
amd: 'react',
},
'react-dom': {
root: 'ReactDOM',
commonjs: 'react-dom',
commonjs2: 'react-dom',
amd: 'react-dom',
},
},
node: {
Buffer: false,
},
plugins: plugins,
};
if (process.env.COMPRESS) {
module.exports.optimization = {
minimize: true,
minimizer: [new TerserPlugin()],
};
}