├── .browserslistrc ├── .gitignore ├── .gitpod.yml ├── .travis.yml ├── LICENSE ├── README.md ├── babelrc ├── cjs │ └── .babelrc ├── default │ └── .babelrc └── esm │ └── .babelrc ├── example ├── example.config.js ├── example.js └── index.html ├── package-lock.json ├── package.json ├── react-dplayer.d.ts ├── src ├── DPlayer.js └── index.js ├── webpack.config.js └── yarn.lock /.browserslistrc: -------------------------------------------------------------------------------- 1 | last 1 version 2 | > 1% 3 | maintained node versions 4 | not dead -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | 8 | # Runtime data 9 | pids 10 | *.pid 11 | *.seed 12 | *.pid.lock 13 | 14 | # Directory for instrumented libs generated by jscoverage/JSCover 15 | lib-cov 16 | 17 | # Coverage directory used by tools like istanbul 18 | coverage 19 | 20 | # nyc test coverage 21 | .nyc_output 22 | 23 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 24 | .grunt 25 | 26 | # Bower dependency directory (https://bower.io/) 27 | bower_components 28 | 29 | # node-waf configuration 30 | .lock-wscript 31 | 32 | # Compiled binary addons (http://nodejs.org/api/addons.html) 33 | build/Release 34 | 35 | # Dependency directories 36 | node_modules/ 37 | jspm_packages/ 38 | 39 | # Typescript v1 declaration files 40 | typings/ 41 | 42 | # Optional npm cache directory 43 | .npm 44 | 45 | # Optional eslint cache 46 | .eslintcache 47 | 48 | # Optional REPL history 49 | .node_repl_history 50 | 51 | # Output of 'npm pack' 52 | *.tgz 53 | 54 | # Yarn Integrity file 55 | .yarn-integrity 56 | 57 | # dotenv environment variables file 58 | .env 59 | 60 | # lib dist 61 | lib 62 | es 63 | dist 64 | 65 | #idea 66 | .idea -------------------------------------------------------------------------------- /.gitpod.yml: -------------------------------------------------------------------------------- 1 | ports: 2 | - port: 8080 3 | onOpen: open-preview 4 | tasks: 5 | - init: yarn 6 | command: yarn start 7 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | 3 | node_js: 4 | - "10" 5 | 6 | notifications: 7 | email: true 8 | 9 | install: yarn install 10 | 11 | script: 12 | - yarn compile 13 | - yarn dist 14 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 hnsylitao 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [![Build Status](https://travis-ci.org/MoePlayer/react-dplayer.svg?branch=master)](https://travis-ci.org/MoePlayer/react-dplayer) 2 | [![Version](https://img.shields.io/npm/v/react-dplayer.svg?style=flat)](https://www.npmjs.com/package/react-dplayer) 3 | [![NPM](https://img.shields.io/npm/dt/react-dplayer.svg?style=flat)](https://www.npmjs.com/package/react-dplayer) 4 | [![LICENSE](https://img.shields.io/badge/license-MIT-green.svg?style=flat)](https://github.com/hnsylitao/react-dplayer/blob/master/LICENSE) 5 | 6 | # react-dplayer [demo](https://codesandbox.io/s/react-dplayer-demo-i61n5) [next demo](https://codesandbox.io/s/next-react-dplayer-7frjk) 7 | 8 | # Gitpod 9 | 10 | Open the project in Gitpod (free online dev environment for GitHub) and start coding immediately. 11 | 12 | [![Open in Gitpod](https://gitpod.io/button/open-in-gitpod.svg)](https://gitpod.io/#https://github.com/MoePlayer/react-dplayer) 13 | 14 | **React component for Dplayer** based on [DPlayer(V1.26.0)](https://github.com/DIYgod/DPlayer). 15 | 16 | ## Install 17 | 18 | ```bash 19 | npm install react-dplayer -D 20 | ``` 21 | 22 | ## Usage 23 | 24 | ### commonjs 25 | 26 | ```js 27 | import DPlayer from "react-dplayer"; 28 | 29 | class Example extends Component { 30 | render() { 31 | return ( 32 | 37 | ) 38 | } 39 | } 40 | ``` 41 | 42 | ### browser 43 | 44 | ```html 45 | 57 | ``` 58 | 59 | The package also includes an in-built example under the `/example` folder. Run the sample application by cloning project and running npm start. 60 | 61 | ## [Dplayer Doc](http://dplayer.js.org/docs/) 62 | 63 | ## Props 64 | 65 | | Name | Type | Default | Description | 66 | | ---- | ---- | ------- | ----------- | 67 | | options | Object | -- | [read doc](http://dplayer.js.org/guide.html#options) | 68 | 69 | ## Events 70 | 71 | > `camel-case rule` example play as onPlay 72 | 73 | | Name | Params | Description | 74 | | ---- | ------ | ----------- | 75 | | allEvent | default | [read doc](http://dplayer.js.org/guide.html#event-binding) | 76 | 77 | ## Development 78 | 79 | - `npm run start`: Run example in development mode 80 | - `npm run compile`: Build react-dplayer(commonjs) 81 | - `npm run dist`: dist react-dplayer (umd) 82 | 83 | ## License 84 | 85 | `react-dplayer` is released under the `MIT license`. 86 | -------------------------------------------------------------------------------- /babelrc/cjs/.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": [ 3 | ["@babel/preset-env", { 4 | "modules": "cjs" 5 | }], 6 | "@babel/preset-react" 7 | ], 8 | "plugins": [ 9 | ["@babel/plugin-transform-modules-commonjs", { 10 | "lazy": true 11 | }] 12 | ] 13 | } -------------------------------------------------------------------------------- /babelrc/default/.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": [ 3 | "@babel/preset-env", 4 | "@babel/preset-react" 5 | ], 6 | "plugins": [] 7 | } -------------------------------------------------------------------------------- /babelrc/esm/.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": [ 3 | ["@babel/preset-env", { 4 | "modules": false 5 | }], 6 | "@babel/preset-react" 7 | ], 8 | "plugins": [] 9 | } -------------------------------------------------------------------------------- /example/example.config.js: -------------------------------------------------------------------------------- 1 | const path = require('path'); 2 | const rootPath = process.cwd(); 3 | const srcPath = path.resolve(rootPath, 'example'); 4 | const webpack = require('webpack'); 5 | const MiniCssExtractPlugin = require('mini-css-extract-plugin'); 6 | const HtmlWebpackPlugin = require('html-webpack-plugin'); 7 | 8 | module.exports = { 9 | mode: 'development', 10 | entry: { 11 | bundle: [path.resolve(srcPath, 'example.js')], 12 | }, 13 | devServer: { 14 | open: true, 15 | https: false, 16 | disableHostCheck: true, 17 | contentBase: srcPath, 18 | historyApiFallback: true, 19 | hot: true, 20 | port: 8080, 21 | publicPath: '', 22 | noInfo: true, 23 | quiet: false, 24 | compress: false, 25 | stats: { colors: true }, 26 | }, 27 | output: { 28 | path: path.resolve(srcPath, '__BUILD__'), 29 | filename: '[name].js', 30 | publicPath: '', 31 | }, 32 | optimization: { 33 | splitChunks: { 34 | cacheGroups: { 35 | styles: { 36 | name: 'styles', 37 | test: /\.css$/, 38 | chunks: 'all', 39 | enforce: true, 40 | }, 41 | }, 42 | }, 43 | }, 44 | devtool: 'cheap-source-map', 45 | plugins: [ 46 | new webpack.HotModuleReplacementPlugin(), 47 | new HtmlWebpackPlugin({ 48 | filename: 'index.html', 49 | template: path.resolve(srcPath, 'index.html'), 50 | }), 51 | new MiniCssExtractPlugin({ 52 | filename: '[name].css', 53 | }), 54 | ], 55 | module: { 56 | rules: [ 57 | { 58 | test: /\.(js|jsx)$/, 59 | exclude: [/node_modules/], 60 | use: [ 61 | { 62 | loader: 'babel-loader', 63 | options: { 64 | configFile: path.resolve(rootPath, 'babelrc/default/.babelrc'), 65 | }, 66 | }, 67 | ], 68 | }, 69 | { 70 | test: /\.css$/, 71 | use: [MiniCssExtractPlugin.loader, 'css-loader'], 72 | }, 73 | ], 74 | }, 75 | }; 76 | -------------------------------------------------------------------------------- /example/example.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import ReactDOM from 'react-dom'; 3 | import reactCreateClass from 'create-react-class'; 4 | import DPlayer from '../lib'; 5 | 6 | const Example = reactCreateClass({ 7 | 8 | getInitialState() { 9 | return { 10 | canplay: false, 11 | play: false, 12 | currentTime: 0, 13 | }; 14 | }, 15 | 16 | seek() { 17 | this.dp.seek(10) 18 | }, 19 | 20 | play() { 21 | this.dp.play() 22 | }, 23 | 24 | pause() { 25 | this.dp.pause() 26 | }, 27 | 28 | onLoad(dp) { 29 | this.dp = dp; 30 | console.log(dp, dp.video); 31 | }, 32 | 33 | onCanplay() { 34 | this.setState({ 35 | canplay: true, 36 | }) 37 | }, 38 | 39 | onPlay() { 40 | this.setState({ 41 | play: true, 42 | }) 43 | }, 44 | 45 | onPause() { 46 | this.setState({ 47 | play: false, 48 | }) 49 | }, 50 | 51 | onEnded() { 52 | console.log('end') 53 | }, 54 | 55 | onError() { 56 | console.log('error') 57 | }, 58 | 59 | onPlaying() { 60 | this.setState({ 61 | currentTime: this.dp.video.currentTime, 62 | }) 63 | }, 64 | 65 | render() { 66 | return ( 67 |
68 | 86 | 87 | 88 | 89 | 90 |

canplay {JSON.stringify(this.state.canplay)}

91 |

play {JSON.stringify(this.state.play)}

92 |

currentTime {this.state.currentTime}

93 |
94 | ); 95 | } 96 | }); 97 | 98 | ReactDOM.render( 99 | , 100 | document.getElementById('example') 101 | ); -------------------------------------------------------------------------------- /example/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | React Dplayer 7 | 8 | 9 | 10 |
11 | 12 | 13 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "react-dplayer", 3 | "version": "0.4.2", 4 | "description": "dplayer", 5 | "main": "lib/index.js", 6 | "module": "es/index.js", 7 | "unpkg": "dist/react-dplayer.min.js", 8 | "types": "react-dplayer.d.ts", 9 | "files": [ 10 | "dist", 11 | "lib", 12 | "es" 13 | ], 14 | "sideEffects": false, 15 | "dependencies": { 16 | "@types/dplayer": "^1.25.0", 17 | "clsx": "^1.1.0", 18 | "dplayer": "^1.26.0", 19 | "omit.js": "^2.0.2" 20 | }, 21 | "devDependencies": { 22 | "@babel/cli": "^7.8.4", 23 | "@babel/core": "^7.9.6", 24 | "@babel/plugin-transform-modules-commonjs": "^7.9.6", 25 | "@babel/preset-env": "^7.9.6", 26 | "@babel/preset-react": "^7.9.4", 27 | "babel-loader": "^8.1.0", 28 | "create-react-class": "^15.6.3", 29 | "html-webpack-plugin": "^4.3.0", 30 | "lodash": "^4.17.15", 31 | "mini-css-extract-plugin": "^1.0.0", 32 | "react": "^16.x", 33 | "react-dom": "^16.x", 34 | "rimraf": "^3.0.2", 35 | "uglifyjs-webpack-plugin": "^2.2.0", 36 | "webpack": "^4.43.0", 37 | "webpack-cli": "^4.0.0", 38 | "webpack-dev-server": "^3.10.3", 39 | "webpack-merge": "^5.1.4" 40 | }, 41 | "peerDependencies": { 42 | "react": "^16.x" 43 | }, 44 | "scripts": { 45 | "dev-server": "webpack-dev-server --config ./example/example.config", 46 | "start": "npm run compile && npm run dev-server", 47 | "prepublish": "npm run prepublish:cjs && npm run prepublish:esm", 48 | "prepublish:esm": "babel ./src --out-dir ./es --config-file ./babelrc/esm/.babelrc", 49 | "prepublish:cjs": "babel ./src --out-dir ./lib --config-file ./babelrc/cjs/.babelrc", 50 | "compile": "rimraf lib/* && rimraf es/* && npm run prepublish", 51 | "dist": "rimraf dist/* && webpack" 52 | }, 53 | "repository": { 54 | "type": "git", 55 | "url": "git+https://github.com/MoePlayer/react-dplayer.git" 56 | }, 57 | "author": "hnsylitao@gmail.com", 58 | "license": "ISC", 59 | "bugs": { 60 | "url": "https://github.com/MoePlayer/react-dplayer/issues" 61 | }, 62 | "homepage": "https://github.com/MoePlayer/react-dplayer#readme" 63 | } 64 | -------------------------------------------------------------------------------- /react-dplayer.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | 3 | declare module "react-dplayer" { 4 | import DPlayer, { DPlayerOptions } from "dplayer"; 5 | import * as React from "react"; 6 | 7 | type DPlayerEventHandle = () => void; 8 | 9 | export interface ReactDplayerProps { 10 | options?: Partial, 11 | onLoad?: (player: DPlayer) => void; 12 | onAbort?: DPlayerEventHandle, 13 | onCanplay?: DPlayerEventHandle, 14 | onCanplaythrough?: DPlayerEventHandle, 15 | onDurationchange?: DPlayerEventHandle, 16 | onEmptied?: DPlayerEventHandle, 17 | onEnded?: DPlayerEventHandle, 18 | onError?: DPlayerEventHandle, 19 | onLoadeddata?: DPlayerEventHandle, 20 | onLoadedmetadata?: DPlayerEventHandle, 21 | onLoadstart?: DPlayerEventHandle, 22 | onMozaudioavailable?: DPlayerEventHandle, 23 | onPause?: DPlayerEventHandle, 24 | onPlay?: DPlayerEventHandle, 25 | onPlaying?: DPlayerEventHandle, 26 | onProgress?: DPlayerEventHandle, 27 | onRatechange?: DPlayerEventHandle, 28 | onSeeked?: DPlayerEventHandle, 29 | onSeeking?: DPlayerEventHandle, 30 | onStalled?: DPlayerEventHandle, 31 | onSuspend?: DPlayerEventHandle, 32 | onTimeupdate?: DPlayerEventHandle, 33 | onVolumechange?: DPlayerEventHandle, 34 | onWaiting?: DPlayerEventHandle, 35 | onScreenshot?: DPlayerEventHandle, 36 | onThumbnailsShow?: DPlayerEventHandle, 37 | onThumbnailsHide?: DPlayerEventHandle, 38 | onDanmakuShow?: DPlayerEventHandle, 39 | onDanmakuHide?: DPlayerEventHandle, 40 | onDanmakuClear?: DPlayerEventHandle, 41 | onDanmakuLoaded?: DPlayerEventHandle, 42 | onDanmakuSend?: DPlayerEventHandle, 43 | onDanmakuOpacity?: DPlayerEventHandle, 44 | onContextmenuShow?: DPlayerEventHandle, 45 | onContextmenuHide?: DPlayerEventHandle, 46 | onNoticeShow?: DPlayerEventHandle, 47 | onNoticeHide?: DPlayerEventHandle, 48 | onQualityStart?: DPlayerEventHandle, 49 | onQualityEnd?: DPlayerEventHandle, 50 | onDestroy?: DPlayerEventHandle, 51 | onResize?: DPlayerEventHandle, 52 | onFullscreen?: DPlayerEventHandle, 53 | onFullscreenCancel?: DPlayerEventHandle, 54 | onSubtitleShow?: DPlayerEventHandle, 55 | onSubtitleHide?: DPlayerEventHandle, 56 | onSubtitleChange?: DPlayerEventHandle, 57 | } 58 | 59 | export default class DPlayerWrap extends React.Component { 60 | dp?: DPlayer; 61 | container?: Element; 62 | } 63 | } -------------------------------------------------------------------------------- /src/DPlayer.js: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | import clsx from 'clsx'; 3 | import omit from 'omit.js'; 4 | import DPlayer from 'dplayer'; 5 | 6 | const events = [ 7 | "abort", "canplay", "canplaythrough", 8 | "durationchange", "emptied", "ended", 9 | "error", "loadeddata", "loadedmetadata", 10 | "loadstart", "mozaudioavailable", "pause", 11 | "play", "playing", "progress", "ratechange", 12 | "seeked", "seeking", "stalled", "suspend", 13 | "timeupdate", "volumechange", "waiting", 14 | "screenshot", "thumbnails_show", "thumbnails_hide", 15 | "danmaku_show", "danmaku_hide", "danmaku_clear", 16 | "danmaku_loaded", "danmaku_send", "danmaku_opacity", 17 | "contextmenu_show", "contextmenu_hide", "notice_show", 18 | "notice_hide", "quality_start", "quality_end", 19 | "destroy", "resize", "fullscreen", "fullscreen_cancel", 20 | "subtitle_show", "subtitle_hide", "subtitle_change" 21 | ]; 22 | const capitalize = function (str) { 23 | return `${str.charAt(0).toUpperCase()}${str.substring(1)}`; 24 | }; 25 | const capitalizeEventName = function (str) { 26 | return str.split('_').map(capitalize).join(''); 27 | }; 28 | const eventsProps = events.map(eventName => ({ eventName, prop: `on${capitalizeEventName(eventName)}` })) 29 | 30 | class DPlayerComponent extends React.Component { 31 | 32 | constructor(props, context) { 33 | super(props, context); 34 | } 35 | 36 | componentDidMount() { 37 | let { onLoad, options } = this.props; 38 | //new player 39 | const player = this.dp = new DPlayer({ 40 | ...Object.assign({}, { 41 | lang: 'zh-cn', 42 | contextmenu: [ 43 | { 44 | text: 'Author', 45 | link: 'https://github.com/hnsylitao' 46 | }, 47 | { 48 | text: 'GitHub', 49 | link: 'https://github.com/MoePlayer/react-dplayer' 50 | } 51 | ], 52 | }, options), 53 | container: this.container 54 | }); 55 | //run load 56 | onLoad && onLoad(player); 57 | //bind player events 58 | eventsProps.forEach(({ eventName, prop }) => { 59 | if (prop in this.props) { 60 | player.on(eventName, this.props[prop]) 61 | } 62 | }) 63 | } 64 | 65 | render() { 66 | const { className, ...otherProps } = this.props; 67 | const resetProps = omit(otherProps, ['options', 'onLoad', ...eventsProps.map(ev => ev.prop)]) 68 | const wrapperClassName = clsx({ 69 | [`dplayer`]: true, 70 | [`${className}`]: !!className, 71 | }); 72 | return
this.container = ref} className={wrapperClassName} {...resetProps} />; 73 | } 74 | } 75 | 76 | export default DPlayerComponent; -------------------------------------------------------------------------------- /src/index.js: -------------------------------------------------------------------------------- 1 | import DPlayer from './DPlayer'; 2 | 3 | export default DPlayer; 4 | -------------------------------------------------------------------------------- /webpack.config.js: -------------------------------------------------------------------------------- 1 | const path = require('path'); 2 | const rootPath = process.cwd(); 3 | const srcPath = path.resolve(rootPath, 'src'); 4 | const pkg = require('./package.json'); 5 | const libraryName = 'ReactDPlayer'; 6 | const webpack = require('webpack'); 7 | const { merge } = require('webpack-merge'); 8 | const MiniCssExtractPlugin = require('mini-css-extract-plugin'); 9 | const UglifyJsPlugin = require('uglifyjs-webpack-plugin'); 10 | 11 | const baseWebpackConfig = { 12 | output: { 13 | path: path.resolve(rootPath, 'dist'), 14 | filename: '[name].js', 15 | chunkFilename: '[name].js', 16 | library: libraryName, 17 | libraryTarget: 'umd', 18 | }, 19 | externals: { 20 | [`react`]: { 21 | root: 'React', 22 | commonjs2: 'react', 23 | commonjs: 'react', 24 | amd: 'react', 25 | }, 26 | [`dplayer`]: 'DPlayer', 27 | }, 28 | devtool: '#sourcemap', 29 | resolve: { 30 | modules: ['node_modules'], 31 | extensions: ['.js', '.jsx', '.json'], 32 | }, 33 | optimization: { 34 | splitChunks: { 35 | cacheGroups: { 36 | styles: { 37 | name: 'styles', 38 | test: /\.css$/, 39 | chunks: 'all', 40 | enforce: true, 41 | }, 42 | }, 43 | }, 44 | }, 45 | module: { 46 | rules: [ 47 | { 48 | test: /\.(js|jsx)$/, 49 | exclude: [/node_modules/], 50 | use: [ 51 | { 52 | loader: 'babel-loader', 53 | options: { 54 | configFile: path.resolve(rootPath, 'babelrc/default/.babelrc'), 55 | }, 56 | }, 57 | ], 58 | }, 59 | { 60 | test: /\.css$/, 61 | use: [MiniCssExtractPlugin.loader, 'css-loader'], 62 | }, 63 | ], 64 | }, 65 | plugins: [ 66 | new MiniCssExtractPlugin({ 67 | filename: '[name].css', 68 | }), 69 | new webpack.optimize.OccurrenceOrderPlugin(), 70 | new webpack.NoEmitOnErrorsPlugin(), 71 | new webpack.BannerPlugin( 72 | `${pkg.name} v${pkg.version} 73 | 74 | Copyright 2017-present, MoePlayer, Inc. 75 | All rights reserved.`, 76 | ), 77 | ], 78 | }; 79 | 80 | const createWebpackConfig = function (config) { 81 | return merge(baseWebpackConfig, config); 82 | }; 83 | 84 | const minWebpackConfig = createWebpackConfig({ 85 | mode: 'production', 86 | entry: { 87 | [`${pkg.name}.min`]: path.resolve(srcPath, 'index.js'), 88 | }, 89 | optimization: { 90 | minimizer: [ 91 | new UglifyJsPlugin({ 92 | uglifyOptions: { 93 | warnings: false, 94 | output: { 95 | ascii_only: true, 96 | }, 97 | }, 98 | sourceMap: true, 99 | }), 100 | ], 101 | }, 102 | plugins: [ 103 | new webpack.DefinePlugin({ 104 | 'process.env.NODE_ENV': JSON.stringify('production'), 105 | }), 106 | ], 107 | }); 108 | 109 | const uncompressedWebpackConfig = createWebpackConfig({ 110 | mode: 'development', 111 | entry: { 112 | [`${pkg.name}`]: path.resolve(srcPath, 'index.js'), 113 | }, 114 | plugins: [ 115 | new webpack.DefinePlugin({ 116 | 'process.env.NODE_ENV': JSON.stringify('development'), 117 | }), 118 | ], 119 | }); 120 | 121 | module.exports = [minWebpackConfig, uncompressedWebpackConfig]; 122 | --------------------------------------------------------------------------------