forked from facebookarchive/fixed-data-table
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
115 lines (102 loc) · 2.61 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
var webpack = require('webpack');
var resolvers = require('./build_helpers/resolvers');
var path = require('path');
var glob = require('glob');
var ExtractTextPlugin = require('extract-text-webpack-plugin');
var packageJSON = require('./package.json');
var banner = (
'/**\n' +
' * FixedDataTable v' + packageJSON.version + ' \n' +
' *\n' +
' * Copyright (c) 2015, Facebook, Inc.\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 ExtractTextPlugin('[name].css'),
new webpack.DefinePlugin({
'__DEV__': JSON.stringify(process.env.NODE_ENV !== 'production')
}),
resolvers.resolveHasteDefines,
];
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) {
plugins.push(
new webpack.optimize.UglifyJsPlugin({
compressor: {
warnings: false
},
output: {comments: false}
})
);
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 = {
module: {
loaders: [
{
test: /\.js$/,
exclude: /node_modules/,
loader: 'babel-loader'
},
{
test: /\.css$/,
loader: ExtractTextPlugin.extract(
'style-loader',
[
'css-loader',
path.join(__dirname, './build_helpers/cssTransformLoader.js')
].join('!')
)
},
],
},
entry: entry,
output: {
library: 'FixedDataTable',
libraryTarget: 'umd',
path: '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
};