diff --git a/.gitignore b/.gitignore index 59a3d09..3d42633 100644 --- a/.gitignore +++ b/.gitignore @@ -32,3 +32,6 @@ node_modules # Optional REPL history .node_repl_history lib + +# Compiled UMD version for https://unpkg.com/ +dist diff --git a/package.json b/package.json index ccb1904..6106ea7 100644 --- a/package.json +++ b/package.json @@ -4,12 +4,13 @@ "description": "Denormalizer for normalizr", "main": "lib/index.js", "files": [ + "dist", "lib" ], "scripts": { "cover": "babel-node ./node_modules/istanbul/lib/cli cover -- _mocha --recursive --reporter spec", "prebuild": "rimraf dist lib", - "build": "babel src --out-dir lib", + "build": "webpack && babel src --out-dir lib", "test": "mocha --compilers js:babel-core/register --recursive", "test:watch": "npm run test -- --watch", "prepublish": "npm run build", @@ -33,7 +34,9 @@ "babel-cli": "^6.16.0", "babel-core": "^6.17.0", "babel-eslint": "^7.0.0", + "babel-loader": "^6.2.5", "babel-preset-es2015": "^6.16.0", + "babel-preset-stage-1": "^6.16.0", "chai": "^3.5.0", "chai-immutable": "^1.5.4", "coveralls": "^2.11.14", @@ -45,7 +48,8 @@ "immutable": "^3.8.1", "istanbul": "^1.1.0-alpha.1", "mocha": "^3.1.0", - "rimraf": "^2.5.4" + "rimraf": "^2.5.4", + "webpack": "^1.13.2" }, "peerDependencies": { "normalizr": "^2.0.0" diff --git a/webpack.config.js b/webpack.config.js new file mode 100644 index 0000000..d3aaa3f --- /dev/null +++ b/webpack.config.js @@ -0,0 +1,35 @@ +var webpack = require('webpack'); + +module.exports = { + entry: './src/index', + module: { + loaders: [ + { + test: /\.js$/, + loader: 'babel', + exclude: /node_modules/, + query: { + presets: ['es2015', 'stage-1'] + } + } + ] + }, + output: { + filename: 'dist/denormalizr.min.js', + libraryTarget: 'umd', + library: 'denormalizr' + }, + plugins: [ + new webpack.optimize.OccurenceOrderPlugin(), + new webpack.DefinePlugin({ + 'process.env': { + 'NODE_ENV': JSON.stringify('production') + } + }), + new webpack.optimize.UglifyJsPlugin({ + compressor: { + warnings: false + } + }) + ] +}; \ No newline at end of file