Skip to content

Commit

Permalink
Add browser build
Browse files Browse the repository at this point in the history
Run `npm run build:browser` to create a standalone js file in `dist`
Resolves cookpete/react-player#35
Also fully resolves cookpete/react-player#38
  • Loading branch information
albanqoku committed Feb 29, 2016
1 parent 87ffd23 commit 12be540
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 3 deletions.
3 changes: 3 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
"env": {
"development": {
"presets": ["react-hmre"]
},
"production": {
"plugins": ["add-module-exports"]
}
}
}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ npm-debug.log
.DS_Store
/lib
/demo
/dist
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ class App extends Component {
}
```

See `App.js` for a full example
See [the demo source](https://github.com/CookPete/react-player/blob/master/src/demo/App.js) for a full example.

For platforms like [Meteor](https://www.meteor.com) without direct use of `npm` modules, a minified version of `ReactPlayer` is located in `dist` after installing. To generate this file yourself, checkout the repo and run `npm run build:browser`

### Demo

Expand Down
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
"description": "A react component for playing a variety of URLs, including file paths, YouTube, SoundCloud and Vimeo",
"main": "lib/ReactPlayer.js",
"scripts": {
"clean": "rimraf lib; rimraf demo",
"clean": "rimraf lib demo dist",
"build:webpack": "NODE_ENV=production webpack --config webpack.config.prod.js",
"build:browser": "NODE_ENV=production webpack --config webpack.config.browser.js",
"build:demo": "npm run clean && npm run build:webpack && cp index.html demo",
"build:compile": "NODE_ENV=production babel src -d lib --ignore src/demo",
"start": "node server.js",
Expand All @@ -15,7 +16,7 @@
"test": "npm run test:mocha && npm run test:karma",
"preversion": "npm run lint && npm run test",
"version": "auto-changelog --package --template compact; git add CHANGELOG.md",
"prepublish": "npm run build:compile",
"prepublish": "npm run build:compile; npm run build:browser",
"postpublish": "npm run clean"
},
"repository": {
Expand Down Expand Up @@ -48,6 +49,7 @@
"babel-core": "^6.3.17",
"babel-eslint": "^5.0.0-beta6",
"babel-loader": "^6.2.0",
"babel-plugin-add-module-exports": "^0.1.2",
"babel-preset-es2015": "^6.3.13",
"babel-preset-react": "^6.3.13",
"babel-preset-react-hmre": "^1.0.1",
Expand Down
34 changes: 34 additions & 0 deletions webpack.config.browser.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
var path = require('path')
var webpack = require('webpack')

module.exports = {
devtool: 'source-map',
entry: './src/ReactPlayer',
output: {
path: path.join(__dirname, 'dist'),
filename: 'ReactPlayer.js'
},
plugins: [
new webpack.optimize.OccurenceOrderPlugin(),
new webpack.DefinePlugin({
'process.env': {
'NODE_ENV': JSON.stringify('production')
}
}),
new webpack.optimize.UglifyJsPlugin({
compressor: {
warnings: false
}
})
],
module: {
loaders: [{
test: /\.js$/,
loader: 'babel',
include: path.join(__dirname, 'src')
}]
},
externals: {
'react': 'React'
}
}

0 comments on commit 12be540

Please sign in to comment.