This repository has been archived by the owner on Dec 2, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
87 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -57,8 +57,9 @@ typings/ | |
# dotenv environment variables file | ||
.env | ||
|
||
# lib | ||
# lib dist | ||
lib | ||
dist | ||
|
||
#idea | ||
.idea |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
* | ||
!lib/* | ||
!lib/* | ||
!dist/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,4 +11,5 @@ notifications: | |
install: npm install --dev | ||
|
||
script: | ||
- npm run compile | ||
- npm run compile | ||
- npm run dist |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
[![Build Status](https://travis-ci.org/hnsylitao/react-dplayer.svg?branch=master)](https://travis-ci.org/hnsylitao/react-dplayer) | ||
[![Version](https://img.shields.io/npm/v/react-dplayer.svg?style=flat)](https://www.npmjs.com/package/react-dplayer) | ||
[![Build Status](https://travis-ci.org/MoePlayer/react-dplayer.svg?branch=master)](https://travis-ci.org/MoePlayer/react-dplayer)[![Version](https://img.shields.io/npm/v/react-dplayer.svg?style=flat)](https://www.npmjs.com/package/react-dplayer) | ||
[![NPM](https://img.shields.io/npm/dt/react-dplayer.svg?style=flat)](https://www.npmjs.com/package/react-dplayer) | ||
[![LICENSE](https://img.shields.io/badge/license-MIT-green.svg?style=flat)](https://github.com/hnsylitao/react-dplayer/blob/master/LICENSE) | ||
|
||
|
@@ -15,6 +14,7 @@ npm install react-dplayer -save | |
|
||
## Usage | ||
|
||
### commonjs | ||
```js | ||
import Dplayer from "react-dplayer"; | ||
|
||
|
@@ -25,12 +25,22 @@ class Example extends Component { | |
|
||
render() { | ||
return ( | ||
<Dplayer /> | ||
<DPlayer video={{ | ||
url: 'http://static.smartisanos.cn/common/video/t1-ui.mp4', | ||
}}/> | ||
) | ||
} | ||
} | ||
``` | ||
|
||
### browser | ||
```html | ||
<link rel="stylesheet" href="https://unpkg.com/[email protected]/dist/DPlayer.min.css"> | ||
<script src="https://unpkg.com/[email protected]/dist/DPlayer.min.js" /> | ||
<script src="https://unpkg.com/[email protected]/dist/react.min.js" /> | ||
<script src="https://unpkg.com/[email protected]/dist/react-dplayer.min.js" /> | ||
``` | ||
The package also includes an in-built example under the `/example` folder. Run the sample application by cloning project and running npm start. | ||
## [Dplayer Doc](http://dplayer.js.org/docs/) | ||
|
@@ -67,7 +77,8 @@ The package also includes an in-built example under the `/example` folder. Run t | |
## Development | ||
- `npm run start`: Run example in development mode | ||
- `npm run compile`: Build react-dplayer | ||
- `npm run compile`: Build react-dplayer(commonjs) | ||
- `npm run dist`: dist react-dplayer (umd) | ||
## License | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
const path = require('path') | ||
, deepAssign = require('deep-assign') | ||
, rootPath = path.resolve(__dirname) | ||
, srcPath = path.resolve(rootPath, 'src') | ||
, pkg = require('./package.json') | ||
, libraryName = (function (str) { | ||
return str.split("-").map(function (c, i) { | ||
return i > 0 ? (c.charAt(0).toUpperCase() + c.substring(1)) : c; | ||
}).join(''); | ||
})(pkg.name) | ||
, webpack = require('atool-build/lib/webpack'); | ||
|
||
module.exports = function (webpackConfig) { | ||
webpackConfig.entry = { | ||
[`${pkg.name}.min`]: path.resolve(srcPath, 'index.js') | ||
} | ||
webpackConfig.externals = { | ||
[`react`]: { | ||
root: 'React', | ||
commonjs2: 'react', | ||
commonjs: 'react', | ||
amd: 'react', | ||
}, | ||
[`dplayer`]: "DPlayer", | ||
[`dplayer/dist/DPlayer.min.css`]: "null", | ||
}; | ||
|
||
/** | ||
* remove commonjs | ||
*/ | ||
webpackConfig.plugins = webpackConfig.plugins.filter((plugin) => { | ||
const ret = !(plugin instanceof webpack.optimize.CommonsChunkPlugin); | ||
return ret; | ||
}); | ||
webpackConfig.output.library = libraryName; | ||
webpackConfig.output.libraryTarget = 'umd'; | ||
webpackConfig.plugins.push(new webpack.BannerPlugin( | ||
`${ pkg.name} v${pkg.version} | ||
Copyright 2017-present, MoePlayer, Inc. | ||
All rights reserved.` | ||
)); | ||
let uncompressedWebpackConfig = deepAssign({}, webpackConfig); | ||
uncompressedWebpackConfig.entry = { | ||
[`${pkg.name}`]: path.resolve(srcPath, 'index.js') | ||
} | ||
uncompressedWebpackConfig.plugins = webpackConfig.plugins.filter((plugin) => { | ||
const ret = !(plugin instanceof webpack.optimize.UglifyJsPlugin); | ||
return ret; | ||
}); | ||
uncompressedWebpackConfig.plugins = uncompressedWebpackConfig.plugins.filter((plugin) => { | ||
const ret = !(plugin instanceof webpack.DefinePlugin); | ||
return ret; | ||
}); | ||
uncompressedWebpackConfig.plugins.push(new webpack.DefinePlugin({ | ||
'process.env.NODE_ENV': JSON.stringify('development'), | ||
})); | ||
|
||
return [webpackConfig, uncompressedWebpackConfig]; | ||
} |