Skip to content

Commit

Permalink
feat(umd): Adding umd support
Browse files Browse the repository at this point in the history
  • Loading branch information
weslleyaraujo committed Mar 2, 2016
1 parent 9e99c17 commit fbb7f1d
Show file tree
Hide file tree
Showing 3 changed files with 54 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 @@ -12,7 +12,11 @@
"prepublish": "npm run test && rimraf lib && npm run build",
"test": "mocha --compilers js:babel-core/register --reporter spec test/*.js",
"posttest": "npm run lint",
"lint": "eslint src test"
"lint": "eslint src test",
"build": "npm run build:commonjs && npm run build:umd && npm run build:umd:min",
"build:commonjs": "babel src --out-dir lib",
"build:umd": "NODE_ENV=development webpack",
"build:umd:min": "NODE_ENV=production webpack"
},
"repository": {
"type": "git",
Expand All @@ -33,6 +37,7 @@
"babel-cli": "^6.2.0",
"babel-core": "^6.2.1",
"babel-eslint": "^5.0.0-beta4",
"babel-loader": "^6.2.4",
"babel-plugin-add-module-exports": "^0.1.1",
"babel-preset-es2015": "^6.1.18",
"babel-preset-stage-0": "^6.1.18",
Expand All @@ -41,6 +46,7 @@
"eslint-config-airbnb": "1.0.2",
"eslint-plugin-react": "^4.1.0",
"mocha": "^2.2.5",
"rimraf": "^2.4.3"
"rimraf": "^2.4.3",
"webpack": "^1.12.14"
}
}
45 changes: 45 additions & 0 deletions webpack.config.babel.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import webpack from 'webpack';
import path from 'path';

const { NODE_ENV, TARGET } = process.env;

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

const filename = `redux-thunk${NODE_ENV === 'production' ? '.min' : ''}.js`;

NODE_ENV === 'production' && plugins.push(
new webpack.optimize.UglifyJsPlugin({
compressor: {
pure_getters: true,
unsafe: true,
unsafe_comps: true,
screw_ie8: true,
warnings: false
}
})
);

export default {
module: {
loaders: [
{ test: /\.js$/, loaders: ['babel-loader'], exclude: /node_modules/ }
]
},

entry: [
'./src/index',
],

output: {
path: path.join(__dirname, 'dist'),
filename,
libraryTarget: 'umd',
},

plugins,
};

0 comments on commit fbb7f1d

Please sign in to comment.