-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathwebpack.config.js
71 lines (68 loc) · 1.86 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
process.env.NODE_ENV = 'production';
var path = require('path');
var webpack = require('webpack');
var ExtractTextPlugin = require('extract-text-webpack-plugin');
var CopyWebpackPlugin = require('copy-webpack-plugin');
var nodeModulesPath = path.join(__dirname, '..', 'node_modules');
var buildPath = path.join(__dirname, 'dist');
var srcPath = path.resolve(__dirname, 'src');
module.exports = {
bail: true,
devtool: 'source-map',
entry: path.join(srcPath, 'index'),
output: {
path: buildPath + '/js/',
filename: 'react-custom-datatable.js',
// TODO: this wouldn't work for e.g. GH Pages.
// Good news: we can infer it from package.json :-)
publicPath: '/',
libraryTarget: 'umd2'
},
resolve: {
alias: {
'react': path.join(__dirname, 'node_modules', 'react')
},
extensions: ['', '.js'],
},
resolveLoader: {
root: nodeModulesPath,
moduleTemplates: ['*-loader']
},
module: {
loaders: [
{
test: /\.js$/,
include: srcPath,
loader: 'babel',
query: require('./babel.prod')
},
{
test: /\.css$/,
include: srcPath,
// Disable autoprefixer in css-loader itself:
// https://github.com/webpack/css-loader/issues/281
// We already have it thanks to postcss.
loader: ExtractTextPlugin.extract('style', 'css?-autoprefixer!postcss')
}
]
},
postcss: function() {
return [autoprefixer];
},
plugins: [
new webpack.DefinePlugin({
'process.env.NODE_ENV': '"production"'
}),
new webpack.optimize.OccurrenceOrderPlugin(),
new webpack.optimize.DedupePlugin(),
new CopyWebpackPlugin([
{from: path.join(srcPath, 'css'), to: '../css'}
]),
new webpack.optimize.UglifyJsPlugin({
compressor: {
warnings: false
},
}),
new ExtractTextPlugin('[name].[contenthash].css')
]
};