Skip to content

Commit fbb7f1d

Browse files
committed
feat(umd): Adding umd support
1 parent 9e99c17 commit fbb7f1d

File tree

3 files changed

+54
-2
lines changed

3 files changed

+54
-2
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ node_modules
22
coverage
33
*.log
44
lib
5+
dist

package.json

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,11 @@
1212
"prepublish": "npm run test && rimraf lib && npm run build",
1313
"test": "mocha --compilers js:babel-core/register --reporter spec test/*.js",
1414
"posttest": "npm run lint",
15-
"lint": "eslint src test"
15+
"lint": "eslint src test",
16+
"build": "npm run build:commonjs && npm run build:umd && npm run build:umd:min",
17+
"build:commonjs": "babel src --out-dir lib",
18+
"build:umd": "NODE_ENV=development webpack",
19+
"build:umd:min": "NODE_ENV=production webpack"
1620
},
1721
"repository": {
1822
"type": "git",
@@ -33,6 +37,7 @@
3337
"babel-cli": "^6.2.0",
3438
"babel-core": "^6.2.1",
3539
"babel-eslint": "^5.0.0-beta4",
40+
"babel-loader": "^6.2.4",
3641
"babel-plugin-add-module-exports": "^0.1.1",
3742
"babel-preset-es2015": "^6.1.18",
3843
"babel-preset-stage-0": "^6.1.18",
@@ -41,6 +46,7 @@
4146
"eslint-config-airbnb": "1.0.2",
4247
"eslint-plugin-react": "^4.1.0",
4348
"mocha": "^2.2.5",
44-
"rimraf": "^2.4.3"
49+
"rimraf": "^2.4.3",
50+
"webpack": "^1.12.14"
4551
}
4652
}

webpack.config.babel.js

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import webpack from 'webpack';
2+
import path from 'path';
3+
4+
const { NODE_ENV, TARGET } = process.env;
5+
6+
const plugins = [
7+
new webpack.optimize.OccurenceOrderPlugin(),
8+
new webpack.DefinePlugin({
9+
'process.env.NODE_ENV': JSON.stringify(NODE_ENV)
10+
}),
11+
];
12+
13+
const filename = `redux-thunk${NODE_ENV === 'production' ? '.min' : ''}.js`;
14+
15+
NODE_ENV === 'production' && plugins.push(
16+
new webpack.optimize.UglifyJsPlugin({
17+
compressor: {
18+
pure_getters: true,
19+
unsafe: true,
20+
unsafe_comps: true,
21+
screw_ie8: true,
22+
warnings: false
23+
}
24+
})
25+
);
26+
27+
export default {
28+
module: {
29+
loaders: [
30+
{ test: /\.js$/, loaders: ['babel-loader'], exclude: /node_modules/ }
31+
]
32+
},
33+
34+
entry: [
35+
'./src/index',
36+
],
37+
38+
output: {
39+
path: path.join(__dirname, 'dist'),
40+
filename,
41+
libraryTarget: 'umd',
42+
},
43+
44+
plugins,
45+
};

0 commit comments

Comments
 (0)