Skip to content

Commit 72c8498

Browse files
committed
Move to using webpack for building the library
This allows us to remove the dependency on browserify completely.
1 parent fe46c63 commit 72c8498

File tree

5 files changed

+50
-21
lines changed

5 files changed

+50
-21
lines changed

.babelrc

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"presets": ["es2015", "react"]
3+
}

package.json

+5-10
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@
2121
],
2222
"license": "MIT",
2323
"devDependencies": {
24-
"browserify": "11.1.0",
25-
"browserify-shim": "3.8.10",
26-
"envify": "3.4.0",
24+
"babel-core": "^6.7.4",
25+
"babel-loader": "^6.2.4",
26+
"babel-preset-es2015": "^6.6.0",
27+
"babel-preset-react": "^6.5.0",
2728
"expect": "1.10.0",
28-
"jsx-loader": "0.13.2",
2929
"karma": "0.13.10",
3030
"karma-browserify": "^4.2.1",
3131
"karma-chrome-launcher": "0.2.0",
@@ -37,7 +37,6 @@
3737
"react": "^0.14.0",
3838
"react-addons-test-utils": "^0.14.0",
3939
"react-dom": "^0.14.0",
40-
"reactify": "^1.1.1",
4140
"rf-release": "0.4.0",
4241
"sinon": "^1.17.3",
4342
"uglify-js": "2.4.24",
@@ -62,9 +61,5 @@
6261
"react-component",
6362
"modal",
6463
"dialog"
65-
],
66-
"browserify-shim": {
67-
"react": "global:React",
68-
"react-dom": "global:ReactDOM"
69-
}
64+
]
7065
}

scripts/build

+1-10
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,2 @@
11
#!/bin/sh
2-
mkdir -p dist
3-
NODE_ENV=production node_modules/.bin/browserify lib/index.js \
4-
-t reactify \
5-
-t browserify-shim \
6-
-t envify \
7-
--detect-globals false \
8-
-s ReactModal > dist/react-modal.js
9-
node_modules/.bin/uglifyjs dist/react-modal.js \
10-
--compress warnings=false > dist/react-modal.min.js
11-
2+
webpack --config webpack.dist.config.js

webpack.config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ module.exports = {
3535

3636
module: {
3737
loaders: [
38-
{ test: /\.js$/, loader: 'jsx-loader?harmony' }
38+
{ test: /\.js$/, loader: 'babel' }
3939
]
4040
},
4141

webpack.dist.config.js

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
var webpack = require('webpack');
2+
var UglifyJsPlugin = webpack.optimize.UglifyJsPlugin;
3+
var env = process.env.WEBPACK_ENV;
4+
5+
module.exports = {
6+
7+
entry: {
8+
'react-modal': './lib/index.js',
9+
'react-modal.min': './lib/index.js'
10+
},
11+
12+
output: {
13+
filename: '[name].js',
14+
chunkFilename: '[id].chunk.js',
15+
path: 'dist',
16+
publicPath: '/',
17+
libraryTarget: 'umd',
18+
library: 'ReactModal'
19+
},
20+
21+
plugins: [
22+
new webpack.DefinePlugin({
23+
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV)
24+
}),
25+
new UglifyJsPlugin({
26+
include: /\.min\.js$/,
27+
minimize: true,
28+
compress: {
29+
warnings: false
30+
}
31+
})
32+
],
33+
34+
module: {
35+
loaders: [
36+
{ test: /\.js?$/, exclude: /node_modules/, loader: 'babel'},
37+
]
38+
}
39+
40+
};

0 commit comments

Comments
 (0)