diff --git a/README.md b/README.md index b03ecb2..a0d5dbf 100644 --- a/README.md +++ b/README.md @@ -41,14 +41,14 @@ See [docs](http://dplayer.js.org/docs) ``` $ npm install -$ npm run start +$ npm run dev ``` ## Make a release ``` $ npm install -$ npm run test +$ npm run build ``` ## Related Projects diff --git a/package.json b/package.json index 06d168e..03427d4 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,8 @@ "main": "dist/DPlayer.min.js", "scripts": { "test": "webpack", - "start": "webpack-dev-server --hot --progress --inline --host 0.0.0.0" + "build": "webpack", + "dev": "WEBPACK_ENV=dev webpack-dev-server --hot --progress --inline --host 0.0.0.0" }, "repository": { "type": "git", diff --git a/webpack.config.js b/webpack.config.js index f8c4c12..b51ed0f 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -2,29 +2,42 @@ var webpack = require('webpack'); var path = require('path'); var autoprefixer = require('autoprefixer'); +var libraryName = 'DPlayer'; +var env = process.env.WEBPACK_ENV; var ROOT_PATH = path.resolve(__dirname); var APP_PATH = path.resolve(ROOT_PATH, 'src'); var BUILD_PATH = path.resolve(ROOT_PATH, 'dist'); -module.exports = { - devtool: 'source-map', +var plugins = []; +if (env !== 'dev') { + plugins.push( + new webpack.optimize.UglifyJsPlugin({ + compress: { + warnings: false + }, + minimize: true + }) + ); +} - entry: './src/DPlayer.js', +module.exports = { + entry: './src/' + libraryName + '.js', output: { path: BUILD_PATH, - filename: 'DPlayer.min.js', - library: 'DPlayer', + filename: libraryName + '.min.js', + library: libraryName, libraryTarget: 'umd', umdNamedDefine: true }, + devtool: 'source-map', + devServer: { - publicPath: "/dist/" + publicPath: "/dist/", }, module: { - // noParse: /node_modules\/hls.js\/dist\/hls.js/, loaders: [ { test: /\.js$/, @@ -46,13 +59,7 @@ module.exports = { ] }, - plugins: [ - new webpack.optimize.UglifyJsPlugin({ - compress: { - warnings: false - } - }) - ], + plugins: plugins, postcss: [ autoprefixer({