Skip to content

Commit 8a65894

Browse files
Add umd bundle via webpack. Fixes #170
1 parent 267430b commit 8a65894

File tree

3 files changed

+37
-2
lines changed

3 files changed

+37
-2
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
node_modules
22
lib/
3+
dist/

package.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"test": "standard && ava",
88
"test:watch": "npm test -- --watch",
99
"clean": "rimraf lib dist",
10-
"build": "babel src --out-dir lib",
10+
"build": "babel src --out-dir lib && webpack && NODE_ENV=production webpack",
1111
"build:watch": "npm run build ./src -- -watch",
1212
"prepublish": "npm run clean && npm run build"
1313
},
@@ -39,13 +39,16 @@
3939
"devDependencies": {
4040
"ava": "^0.16.0",
4141
"babel-cli": "^6.14.0",
42+
"babel-core": "^6.14.0",
4243
"babel-eslint": "^6.0.0",
44+
"babel-loader": "^6.2.5",
4345
"babel-preset-es2015": "^6.14.0",
4446
"babel-preset-stage-2": "^6.5.0",
4547
"immutable": "^3.7.6",
4648
"redux": "^3.5.2",
4749
"rimraf": "~2.5.2",
48-
"standard": "^8.0.0"
50+
"standard": "^8.0.0",
51+
"webpack": "^1.13.2"
4952
},
5053
"files": [
5154
"lib",

webpack.config.js

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
const webpack = require('webpack')
2+
const env = process.env.NODE_ENV
3+
const isProd = env === 'production'
4+
5+
let plugins = [
6+
new webpack.optimize.OccurrenceOrderPlugin(),
7+
new webpack.DefinePlugin({
8+
'process.env.NODE_ENV': JSON.stringify(env)
9+
})
10+
]
11+
12+
if (isProd) {
13+
plugins.push(new webpack.optimize.UglifyJsPlugin({ minimize: true }))
14+
}
15+
16+
module.exports = {
17+
entry: './src/index.js',
18+
output: {
19+
path: 'dist/',
20+
filename: isProd ? 'redux-persist.min.js' : 'redux-persist.js',
21+
library: 'redux-persist',
22+
libraryTarget: 'umd'
23+
},
24+
devtool: 'source-map',
25+
plugins,
26+
module: {
27+
loaders: [
28+
{ test: /\.js$/, loader: 'babel-loader', exclude: /node_modules/ }
29+
]
30+
}
31+
}

0 commit comments

Comments
 (0)