Skip to content
This repository was archived by the owner on Dec 2, 2020. It is now read-only.

Commit 4f05bab

Browse files
committed
0.0.2 in browser
1 parent 79f4f38 commit 4f05bab

File tree

6 files changed

+87
-10
lines changed

6 files changed

+87
-10
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,9 @@ typings/
5757
# dotenv environment variables file
5858
.env
5959

60-
# lib
60+
# lib dist
6161
lib
62+
dist
6263

6364
#idea
6465
.idea

.npmignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
*
2-
!lib/*
2+
!lib/*
3+
!dist/*

.travis.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,5 @@ notifications:
1111
install: npm install --dev
1212

1313
script:
14-
- npm run compile
14+
- npm run compile
15+
- npm run dist

README.md

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
[![Build Status](https://travis-ci.org/hnsylitao/react-dplayer.svg?branch=master)](https://travis-ci.org/hnsylitao/react-dplayer)
2-
[![Version](https://img.shields.io/npm/v/react-dplayer.svg?style=flat)](https://www.npmjs.com/package/react-dplayer)
1+
[![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)
32
[![NPM](https://img.shields.io/npm/dt/react-dplayer.svg?style=flat)](https://www.npmjs.com/package/react-dplayer)
43
[![LICENSE](https://img.shields.io/badge/license-MIT-green.svg?style=flat)](https://github.com/hnsylitao/react-dplayer/blob/master/LICENSE)
54

@@ -15,6 +14,7 @@ npm install react-dplayer -save
1514

1615
## Usage
1716

17+
### commonjs
1818
```js
1919
import Dplayer from "react-dplayer";
2020

@@ -25,12 +25,22 @@ class Example extends Component {
2525

2626
render() {
2727
return (
28-
<Dplayer />
28+
<DPlayer video={{
29+
url: 'http://static.smartisanos.cn/common/video/t1-ui.mp4',
30+
}}/>
2931
)
3032
}
3133
}
3234
```
3335

36+
### browser
37+
```html
38+
<link rel="stylesheet" href="https://unpkg.com/[email protected]/dist/DPlayer.min.css">
39+
<script src="https://unpkg.com/[email protected]/dist/DPlayer.min.js" />
40+
<script src="https://unpkg.com/[email protected]/dist/react.min.js" />
41+
<script src="https://unpkg.com/[email protected]/dist/react-dplayer.min.js" />
42+
```
43+
3444
The package also includes an in-built example under the `/example` folder. Run the sample application by cloning project and running npm start.
3545
3646
## [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
6777
## Development
6878
6979
- `npm run start`: Run example in development mode
70-
- `npm run compile`: Build react-dplayer
80+
- `npm run compile`: Build react-dplayer(commonjs)
81+
- `npm run dist`: dist react-dplayer (umd)
7182
7283
## License
7384

package.json

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
{
22
"name": "react-dplayer",
3-
"version": "0.0.1",
3+
"version": "0.0.2",
44
"description": "dplayer",
55
"main": "lib/index.js",
66
"scripts": {
77
"dev-server": "webpack-dev-server --config ./example/example.config",
8-
"start": "npm run compile; npm run devServer",
8+
"start": "npm run compile; npm run dev-server",
99
"prepublish": "babel ./src --out-dir ./lib",
10-
"compile": "rimraf lib/* && npm run prepublish"
10+
"compile": "rimraf lib/* && npm run prepublish",
11+
"dist": "rimraf dist/* && atool-build --devtool=#sourcemap"
1112
},
1213
"repository": {
1314
"type": "git",
@@ -29,13 +30,15 @@
2930
"prop-types": "^15.5.10"
3031
},
3132
"devDependencies": {
33+
"atool-build": "^1.0.2",
3234
"babel-cli": "^6.26.0",
3335
"babel-loader": "^7.1.2",
3436
"babel-preset-es2015": "^6.24.1",
3537
"babel-preset-react": "^6.24.1",
3638
"babel-preset-stage-0": "^6.24.1",
3739
"create-react-class": "^15.6.0",
3840
"css-loader": "^0.28.5",
41+
"deep-assign": "^2.0.0",
3942
"extract-text-webpack-plugin": "^3.0.0",
4043
"html-webpack-plugin": "^2.30.1",
4144
"react": "^15.6.1",

webpack.config.js

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
const path = require('path')
2+
, deepAssign = require('deep-assign')
3+
, rootPath = path.resolve(__dirname)
4+
, srcPath = path.resolve(rootPath, 'src')
5+
, pkg = require('./package.json')
6+
, libraryName = (function (str) {
7+
return str.split("-").map(function (c, i) {
8+
return i > 0 ? (c.charAt(0).toUpperCase() + c.substring(1)) : c;
9+
}).join('');
10+
})(pkg.name)
11+
, webpack = require('atool-build/lib/webpack');
12+
13+
module.exports = function (webpackConfig) {
14+
webpackConfig.entry = {
15+
[`${pkg.name}.min`]: path.resolve(srcPath, 'index.js')
16+
}
17+
webpackConfig.externals = {
18+
[`react`]: {
19+
root: 'React',
20+
commonjs2: 'react',
21+
commonjs: 'react',
22+
amd: 'react',
23+
},
24+
[`dplayer`]: "DPlayer",
25+
[`dplayer/dist/DPlayer.min.css`]: "null",
26+
};
27+
28+
/**
29+
* remove commonjs
30+
*/
31+
webpackConfig.plugins = webpackConfig.plugins.filter((plugin) => {
32+
const ret = !(plugin instanceof webpack.optimize.CommonsChunkPlugin);
33+
return ret;
34+
});
35+
webpackConfig.output.library = libraryName;
36+
webpackConfig.output.libraryTarget = 'umd';
37+
webpackConfig.plugins.push(new webpack.BannerPlugin(
38+
`${ pkg.name} v${pkg.version}
39+
40+
Copyright 2017-present, MoePlayer, Inc.
41+
All rights reserved.`
42+
));
43+
let uncompressedWebpackConfig = deepAssign({}, webpackConfig);
44+
uncompressedWebpackConfig.entry = {
45+
[`${pkg.name}`]: path.resolve(srcPath, 'index.js')
46+
}
47+
uncompressedWebpackConfig.plugins = webpackConfig.plugins.filter((plugin) => {
48+
const ret = !(plugin instanceof webpack.optimize.UglifyJsPlugin);
49+
return ret;
50+
});
51+
uncompressedWebpackConfig.plugins = uncompressedWebpackConfig.plugins.filter((plugin) => {
52+
const ret = !(plugin instanceof webpack.DefinePlugin);
53+
return ret;
54+
});
55+
uncompressedWebpackConfig.plugins.push(new webpack.DefinePlugin({
56+
'process.env.NODE_ENV': JSON.stringify('development'),
57+
}));
58+
59+
return [webpackConfig, uncompressedWebpackConfig];
60+
}

0 commit comments

Comments
 (0)