forked from sean-ww/react-redux-datatable
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.umd.config.js
92 lines (87 loc) · 2.93 KB
/
webpack.umd.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
// this is just to build a umd build for https://npmcdn.com/
// and for users that don't use webpack or browserify
// For npm package authors, npmcdn relieves the burden of publishing
// your code to a CDN in addition to the npm registry.
// All you need to do is include your UMD build in your npm package
// (not your repo, that's different!).
// You can do this easily using the following setup:
// - Add the umd (or dist in this case) directory to your .gitignore file
// - Add the dist directory to your files array in package.json
// - Use a build script to generate your UMD build in the dist directory just before you publish
// - That's it! Now when you npm publish you'll have a version available on npmcdn as well
var webpack = require('webpack');
var path = require('path');
var colors = require('colors/safe');
var isCoverage = process.env.BABEL_ENV === 'test';
module.exports = {
context: __dirname,
devtool: '#cheap-module-source-map',
entry: {
'react-redux-datatable': 'src/index.jsx'
},
externals: [{
'react': {
root: 'React',
commonjs2: 'react',
commonjs: 'react',
amd: 'react'
}
}, {
'react-dom': {
root: 'ReactDOM',
commonjs2: 'react-dom',
commonjs: 'react-dom',
amd: 'react-dom'
}
}],
module: {
rules: [
{
test: /\.jsx?$/,
exclude: /(node_modules|bower_components|\.spec\.js)/,
enforce: 'pre',
loader: 'eslint-loader'
},
{
test: /\.jsx?$/,
exclude: /(node_modules|bower_components)/,
loader: 'babel-loader',
options: {
presets: ['react', 'es2015', 'stage-0'],
plugins: [].concat(isCoverage ? ['istanbul'] : [],
[
'react-html-attrs',
'transform-decorators-legacy',
'transform-class-properties',
'transform-object-assign',
'webpack-alias'
]
)
}
}
]
},
resolve: {
modules: [
path.resolve(__dirname),
'node_modules'
],
alias: {},
extensions: ['.js', '.jsx'],
},
output: {
path: __dirname + '/dist/',
filename: '[name].js',
library: 'ReactReduxDataTable',
libraryTarget: 'umd'
},
plugins: [
function() {
this.plugin('watch-run', function(watching, callback) {
console.log(colors.green('Start (UMD Build): '), colors.bgBlue.white(new Date()));
callback();
})
},
new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/), // Ignore all optional deps of moment.js
]
};