Skip to content

Commit

Permalink
Move to using webpack for building the library
Browse files Browse the repository at this point in the history
This allows us to remove the dependency on browserify
completely.
  • Loading branch information
claydiffrient committed Mar 27, 2016
1 parent fe46c63 commit 72c8498
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 21 deletions.
3 changes: 3 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"presets": ["es2015", "react"]
}
15 changes: 5 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@
],
"license": "MIT",
"devDependencies": {
"browserify": "11.1.0",
"browserify-shim": "3.8.10",
"envify": "3.4.0",
"babel-core": "^6.7.4",
"babel-loader": "^6.2.4",
"babel-preset-es2015": "^6.6.0",
"babel-preset-react": "^6.5.0",
"expect": "1.10.0",
"jsx-loader": "0.13.2",
"karma": "0.13.10",
"karma-browserify": "^4.2.1",
"karma-chrome-launcher": "0.2.0",
Expand All @@ -37,7 +37,6 @@
"react": "^0.14.0",
"react-addons-test-utils": "^0.14.0",
"react-dom": "^0.14.0",
"reactify": "^1.1.1",
"rf-release": "0.4.0",
"sinon": "^1.17.3",
"uglify-js": "2.4.24",
Expand All @@ -62,9 +61,5 @@
"react-component",
"modal",
"dialog"
],
"browserify-shim": {
"react": "global:React",
"react-dom": "global:ReactDOM"
}
]
}
11 changes: 1 addition & 10 deletions scripts/build
Original file line number Diff line number Diff line change
@@ -1,11 +1,2 @@
#!/bin/sh
mkdir -p dist
NODE_ENV=production node_modules/.bin/browserify lib/index.js \
-t reactify \
-t browserify-shim \
-t envify \
--detect-globals false \
-s ReactModal > dist/react-modal.js
node_modules/.bin/uglifyjs dist/react-modal.js \
--compress warnings=false > dist/react-modal.min.js

webpack --config webpack.dist.config.js
2 changes: 1 addition & 1 deletion webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ module.exports = {

module: {
loaders: [
{ test: /\.js$/, loader: 'jsx-loader?harmony' }
{ test: /\.js$/, loader: 'babel' }
]
},

Expand Down
40 changes: 40 additions & 0 deletions webpack.dist.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
var webpack = require('webpack');
var UglifyJsPlugin = webpack.optimize.UglifyJsPlugin;
var env = process.env.WEBPACK_ENV;

module.exports = {

entry: {
'react-modal': './lib/index.js',
'react-modal.min': './lib/index.js'
},

output: {
filename: '[name].js',
chunkFilename: '[id].chunk.js',
path: 'dist',
publicPath: '/',
libraryTarget: 'umd',
library: 'ReactModal'
},

plugins: [
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV)
}),
new UglifyJsPlugin({
include: /\.min\.js$/,
minimize: true,
compress: {
warnings: false
}
})
],

module: {
loaders: [
{ test: /\.js?$/, exclude: /node_modules/, loader: 'babel'},
]
}

};

0 comments on commit 72c8498

Please sign in to comment.