Skip to content

Commit

Permalink
umd build
Browse files Browse the repository at this point in the history
  • Loading branch information
Malte W committed Feb 15, 2016
1 parent bfe3282 commit f632d08
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 4 deletions.
3 changes: 2 additions & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
lib
**/node_modules
**/webpack.config.js
examples/**/server.js
**/prepublish.js
examples/**/server.js
7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@
"scripts": {
"clean": "rimraf lib dist",
"build": "babel src --out-dir lib",
"build:umd": "webpack src/index.js dist/react-custom-scrollbars.js && NODE_ENV=production webpack src/index.js dist/react-custom-scrollbars.min.js",
"build:umd": "NODE_ENV=development webpack src/index.js dist/react-custom-scrollbars.js",
"build:umd:min": "NODE_ENV=production webpack src/index.js dist/react-custom-scrollbars.min.js",
"lint": "eslint src test examples",
"test": "NODE_ENV=test karma start",
"test:watch": "NODE_ENV=test karma start --auto-watch --no-single-run",
"test:cov": "NODE_ENV=test COVERAGE=true karma start --single-run",
"prepublish": "npm run lint && npm run test && npm run clean && npm run build"
"prepublish": "npm run lint && npm run test && npm run clean && npm run build && npm run build:umd && npm run build:umd:min && node ./prepublish"
},
"repository": {
"type": "git",
Expand Down Expand Up @@ -41,10 +42,12 @@
"babel-preset-stage-1": "^6.1.18",
"babel-register": "^6.3.13",
"babel-runtime": "^6.3.19",
"es3ify": "^0.2.1",
"eslint": "^1.6.0",
"eslint-config-airbnb": "^5.0.0",
"eslint-plugin-react": "^3.5.1",
"expect": "^1.6.0",
"glob": "^7.0.0",
"isparta-loader": "^2.0.0",
"karma": "^0.13.10",
"karma-chrome-launcher": "^0.2.1",
Expand Down
17 changes: 17 additions & 0 deletions prepublish.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
var glob = require('glob');
var fs = require('fs');
var es3ify = require('es3ify');

glob('./@(lib|dist)/**/*.js', function (err, files) {
if (err) throw err;

files.forEach(function(file) {
fs.readFile(file, 'utf8', function (err, data) {
if (err) throw err;
fs.writeFile(file, es3ify.transform(data), function (err) {
if (err) throw err
console.log('es3ified ' + file);
})
})
})
})
10 changes: 9 additions & 1 deletion webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,14 @@ if (process.env.NODE_ENV === 'production') {
}

module.exports = {
externals: {
react: {
root: 'React',
commonjs2: 'react',
commonjs: 'react',
amd: 'react'
}
},
module: {
loaders: [{
test: /\.js$/,
Expand All @@ -29,7 +37,7 @@ module.exports = {
}]
},
output: {
library: 'react-custom-scrollbars',
library: 'ReactCustomScrollbars',
libraryTarget: 'umd'
},
plugins: plugins,
Expand Down

0 comments on commit f632d08

Please sign in to comment.