Skip to content

Commit

Permalink
Create a umd-build script
Browse files Browse the repository at this point in the history
  • Loading branch information
supasate committed Feb 19, 2017
1 parent e6dc165 commit bfae644
Show file tree
Hide file tree
Showing 4 changed files with 530 additions and 21 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
*.swp
node_modules
lib
umd
11 changes: 8 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,14 @@
"files": [
"*.md",
"*.js",
"lib"
"lib",
"umd"
],
"scripts": {
"build:commonjs": "BABEL_ENV=commonjs babel src --out-dir lib",
"build": "npm run build:commonjs",
"build:umd": "NODE_ENV=development webpack src/index.js umd/ConnectedReactRouter.js",
"build:umd:min": "NODE_ENV=production webpack -p src/index.js umd/ConnectedReactRouter.min.js",
"build": "npm run build:commonjs & npm run build:umd & npm run build:umd:min",
"lint": "eslint .",
"test": "jest --config ./.jestrc",
"test:watch": "npm run test -- --watch",
Expand All @@ -33,6 +36,7 @@
"babel-core": "^6.20.0",
"babel-eslint": "^7.1.1",
"babel-jest": "^17.0.2",
"babel-loader": "^6.3.1",
"babel-plugin-rewire": "^1.0.0",
"babel-preset-es2015": "^6.18.0",
"babel-preset-react": "^6.16.0",
Expand All @@ -51,7 +55,8 @@
"redux": "^3.6.0",
"redux-immutable": "^3.0.11",
"redux-mock-store": "^1.2.1",
"rewire": "^2.5.2"
"rewire": "^2.5.2",
"webpack": "^2.2.1"
},
"repository": {
"type": "git",
Expand Down
23 changes: 23 additions & 0 deletions webpack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
var webpack = require('webpack')

var config = {
entry: './src/index',
module: {
rules: [
{ test: /\.js$/, use: [ 'babel-loader' ], exclude: /node_modules/ }
]
},
output: {
library: 'ConnectedReactRouter',
libraryTarget: 'umd'
}
}

if (process.env.NODE_ENV === 'production') {
config.plugins = [
new webpack.optimize.UglifyJsPlugin({ sourceMap: true }),
new webpack.LoaderOptionsPlugin({ minimize: true })
]
}

module.exports = config
Loading

0 comments on commit bfae644

Please sign in to comment.