Skip to content

Commit

Permalink
Add UMD builds
Browse files Browse the repository at this point in the history
Made redux-sounds compatible with single-file UMD builds. Add the
<script> tag to your file, and reference the middleware as ReduxSounds.
  • Loading branch information
joshwcomeau committed Jan 30, 2016
1 parent 7514832 commit 0f4808e
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 2 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ node_modules
coverage
*.log
lib
dist
10 changes: 8 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,16 @@
"description": "Sound effect middleware for Redux.",
"main": "lib/index.js",
"files": [
"dist",
"lib",
"src"
],
"scripts": {
"lint": "eslint src",
"build": "babel src --out-dir lib",
"build:lib": "babel src --out-dir lib",
"build:umd": "webpack src/index.js dist/redux-sounds.js --config webpack.config.development.js",
"build:umd:min": "webpack src/index.js dist/redux-sounds.min.js --config webpack.config.production.js",
"build": "npm run build:lib && npm run build:umd && npm run build:umd:min",
"test": "mocha --compilers js:babel-core/register --reporter spec test/*.js"
},
"repository": {
Expand All @@ -34,6 +38,7 @@
"babel-cli": "^6.2.0",
"babel-core": "^6.2.1",
"babel-eslint": "^5.0.0-beta4",
"babel-loader": "^6.2.1",
"babel-plugin-add-module-exports": "^0.1.1",
"babel-plugin-transform-object-assign": "^6.3.13",
"babel-preset-es2015": "^6.1.18",
Expand All @@ -43,6 +48,7 @@
"eslint-config-airbnb": "^3.1.0",
"mocha": "^2.2.5",
"sinon": "^1.17.2",
"sinon-chai": "^2.8.0"
"sinon-chai": "^2.8.0",
"webpack": "^1.12.11"
}
}
23 changes: 23 additions & 0 deletions webpack.config.base.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
var webpack = require('webpack');

module.exports = {
output: {
library: 'ReduxSounds',
libraryTarget: 'umd'
},

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

resolve: {
extensions: ['', '.js']
}
}
15 changes: 15 additions & 0 deletions webpack.config.development.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
'use strict';

var webpack = require('webpack');
var baseConfig = require('./webpack.config.base');

var config = Object.create(baseConfig);

config.plugins = [
new webpack.optimize.OccurrenceOrderPlugin(),
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify('development')
})
];

module.exports = config;
21 changes: 21 additions & 0 deletions webpack.config.production.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
'use strict';

var webpack = require('webpack');
var baseConfig = require('./webpack.config.base');

var config = Object.create(baseConfig);

config.plugins = [
new webpack.optimize.OccurrenceOrderPlugin(),
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify('production')
}),
new webpack.optimize.UglifyJsPlugin({
compressor: {
screw_ie8: true,
warnings: false
}
})
];

module.exports = config;

0 comments on commit 0f4808e

Please sign in to comment.