diff --git a/.babelrc b/.babelrc new file mode 100644 index 00000000..facd1809 --- /dev/null +++ b/.babelrc @@ -0,0 +1,3 @@ +{ + "presets": ["es2015", "react"] +} \ No newline at end of file diff --git a/package.json b/package.json index baece9d3..b6c8f71a 100644 --- a/package.json +++ b/package.json @@ -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", @@ -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", @@ -62,9 +61,5 @@ "react-component", "modal", "dialog" - ], - "browserify-shim": { - "react": "global:React", - "react-dom": "global:ReactDOM" - } + ] } diff --git a/scripts/build b/scripts/build index b9cd5395..ae0f6d1c 100755 --- a/scripts/build +++ b/scripts/build @@ -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 \ No newline at end of file diff --git a/webpack.config.js b/webpack.config.js index b99a8eef..b15571c6 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -35,7 +35,7 @@ module.exports = { module: { loaders: [ - { test: /\.js$/, loader: 'jsx-loader?harmony' } + { test: /\.js$/, loader: 'babel' } ] }, diff --git a/webpack.dist.config.js b/webpack.dist.config.js new file mode 100644 index 00000000..4ac98798 --- /dev/null +++ b/webpack.dist.config.js @@ -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'}, + ] + } + +}; \ No newline at end of file