Skip to content

Commit 579068f

Browse files
committed
Merge branch 'jochenberger-add-umd-build' into develop
2 parents 587521a + f1a7458 commit 579068f

3 files changed

Lines changed: 139 additions & 1 deletion

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"test-watch": "karma start",
99
"prepare-build": "npm run lint && rimraf dist/",
1010
"prebuild": "npm run prepare-build",
11-
"build": "jsx -x jsx ./src ./dist & jsx ./src ./dist",
11+
"build": "jsx -x jsx ./src ./dist & jsx ./src ./dist && webpack --stats --config webpack.config.umd.prod.js && webpack --stats --config webpack.config.umd.dev.js",
1212
"lint": "eslint src --ext .jsx,.js",
1313
"start": "NODE_ENV=development node devServer.js",
1414
"build:example": "rimraf example/build/ && webpack --stats --config webpack.config.prod.js"

webpack.config.umd.dev.js

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
var path = require('path');
2+
var webpack = require('webpack');
3+
4+
var JS_REGEX = /\.js$|\.jsx$|\.es6$|\.babel$/;
5+
6+
module.exports = {
7+
entry: [
8+
'./src/NotificationSystem.jsx'
9+
],
10+
output: {
11+
path: path.join(__dirname, 'dist'),
12+
filename: 'react-notification-system.js',
13+
libraryTarget: 'umd'
14+
},
15+
externals: [
16+
{
17+
react: {
18+
root: 'React',
19+
commonjs2: 'react',
20+
commonjs: 'react',
21+
amd: 'react'
22+
}
23+
},
24+
{
25+
'react-dom': {
26+
root: 'ReactDOM',
27+
commonjs2: 'react-dom',
28+
commonjs: 'react-dom',
29+
amd: 'react-dom'
30+
}
31+
}
32+
],
33+
plugins: [
34+
new webpack.NoErrorsPlugin()
35+
],
36+
resolve: {
37+
extensions: ['', '.js', '.jsx'],
38+
modulesDirectories: ['node_modules', 'src']
39+
},
40+
module: {
41+
loaders: [
42+
{
43+
test: JS_REGEX,
44+
include: [
45+
path.resolve(__dirname, 'src'),
46+
path.resolve(__dirname, 'example/src')
47+
],
48+
loader: 'babel?presets=airbnb'
49+
}
50+
]
51+
}
52+
};

webpack.config.umd.prod.js

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
var path = require('path');
2+
var webpack = require('webpack');
3+
4+
var JS_REGEX = /\.js$|\.jsx$|\.es6$|\.babel$/;
5+
6+
module.exports = {
7+
entry: [
8+
'./src/NotificationSystem.jsx'
9+
],
10+
output: {
11+
path: path.join(__dirname, 'dist'),
12+
filename: 'react-notification-system.min.js',
13+
libraryTarget: 'umd'
14+
},
15+
devtool: 'source-map',
16+
externals: [
17+
{
18+
react: {
19+
root: 'React',
20+
commonjs2: 'react',
21+
commonjs: 'react',
22+
amd: 'react'
23+
}
24+
},
25+
{
26+
'react-dom': {
27+
root: 'ReactDOM',
28+
commonjs2: 'react-dom',
29+
commonjs: 'react-dom',
30+
amd: 'react-dom'
31+
}
32+
}
33+
],
34+
plugins: [
35+
// set env
36+
new webpack.DefinePlugin({
37+
'process.env': {
38+
BROWSER: JSON.stringify(true),
39+
NODE_ENV: JSON.stringify('production')
40+
}
41+
}),
42+
43+
// optimizations
44+
new webpack.optimize.DedupePlugin(),
45+
new webpack.optimize.OccurenceOrderPlugin(),
46+
new webpack.optimize.UglifyJsPlugin({
47+
compress: {
48+
warnings: false,
49+
screw_ie8: true,
50+
sequences: true,
51+
dead_code: true,
52+
drop_debugger: true,
53+
comparisons: true,
54+
conditionals: true,
55+
evaluate: true,
56+
booleans: true,
57+
loops: true,
58+
unused: true,
59+
hoist_funs: true,
60+
if_return: true,
61+
join_vars: true,
62+
cascade: true,
63+
drop_console: false
64+
},
65+
output: {
66+
comments: false
67+
}
68+
})
69+
],
70+
resolve: {
71+
extensions: ['', '.js', '.jsx'],
72+
modulesDirectories: ['node_modules', 'src']
73+
},
74+
module: {
75+
loaders: [
76+
{
77+
test: JS_REGEX,
78+
include: [
79+
path.resolve(__dirname, 'src'),
80+
path.resolve(__dirname, 'example/src')
81+
],
82+
loader: 'babel?presets=airbnb'
83+
}
84+
]
85+
}
86+
};

0 commit comments

Comments
 (0)