From d62405e8ff4147f29dd7b8cedd1d44f8064dd0a2 Mon Sep 17 00:00:00 2001 From: Harvey Zack Date: Fri, 30 Nov 2018 09:49:25 +0800 Subject: [PATCH] dev init --- package.json | 32 ++++++++-- .../artplayer-plugin-subtitle/package.json | 28 +-------- script/dev.js | 0 script/rollup.config.js | 63 +++++++++++++++++++ 4 files changed, 92 insertions(+), 31 deletions(-) create mode 100644 script/dev.js create mode 100644 script/rollup.config.js diff --git a/package.json b/package.json index 8410bbae4..7bd2b0907 100644 --- a/package.json +++ b/package.json @@ -3,9 +3,10 @@ "version": "1.0.0", "description": "ArtPlayer is a modern HTML5 video player", "scripts": { - "bootstrap": "lerna bootstrap", - "publish": "lerna publish", - "build": "lerna run build", + "bootstrap": "node ./node_modules/.bin/lerna bootstrap", + "publish": "node ./node_modules/.bin/lerna publish", + "dev": "node ./node_modules/.bin/cross-env NODE_ENV=development node ./script/dev.js", + "build": "node ./node_modules/.bin/cross-env NODE_ENV=production node ./script/build.js", "test": "node ./node_modules/.bin/mocha-chrome ./docs/test/index.html --mocha '{\"ui\":\"bdd\"}'", "lint": "node ./node_modules/.bin/eslint packages/*/src" }, @@ -24,14 +25,37 @@ }, "homepage": "https://github.com/zhw2590582/ArtPlayer#readme", "devDependencies": { + "@babel/core": "^7.1.2", + "@babel/plugin-external-helpers": "^7.0.0", + "@babel/plugin-transform-runtime": "^7.1.0", + "@babel/preset-env": "^7.1.0", + "@babel/runtime": "^7.1.2", + "autoprefixer": "^9.3.1", "babel-eslint": "^10.0.1", + "browser-env": "^3.2.5", "chai": "^4.2.0", + "chalk": "^2.4.1", + "cross-env": "^5.2.0", + "cssnano": "^4.1.7", "eslint": "^5.9.0", "eslint-config-airbnb-base": "^13.1.0", "eslint-config-prettier": "^3.3.0", "eslint-plugin-import": "^2.14.0", + "glob": "^7.1.3", + "inquirer": "^6.2.0", "lerna": "^3.4.3", "mocha": "^5.2.0", - "mocha-chrome": "^1.1.0" + "mocha-chrome": "^1.1.0", + "node-sass": "^4.9.4", + "ora": "^3.0.0", + "rollup": "^0.67.0", + "rollup-plugin-babel": "^4.0.3", + "rollup-plugin-commonjs": "^9.2.0", + "rollup-plugin-eslint": "^5.0.0", + "rollup-plugin-node-resolve": "^3.4.0", + "rollup-plugin-postcss": "^1.6.2", + "rollup-plugin-replace": "^2.1.0", + "rollup-plugin-svgo": "^1.0.1", + "rollup-plugin-uglify": "^6.0.0" } } diff --git a/packages/artplayer-plugin-subtitle/package.json b/packages/artplayer-plugin-subtitle/package.json index 3d50b0893..7a1610b93 100644 --- a/packages/artplayer-plugin-subtitle/package.json +++ b/packages/artplayer-plugin-subtitle/package.json @@ -4,11 +4,6 @@ "description": "Danmu plugin for ArtPlayer", "main": "dist/artplayer-plugin-subtitle.js", "style": "dist/artplayer-plugin-subtitle.css", - "scripts": { - "dev": "cross-env NODE_ENV=development rollup -c -m -w", - "build": "cross-env NODE_ENV=production rollup -c", - "test": "echo \"Error: no test specified\" && exit 1" - }, "repository": { "type": "git", "url": "git+https://github.com/zhw2590582/ArtPlayer.git" @@ -22,26 +17,5 @@ "bugs": { "url": "https://github.com/zhw2590582/ArtPlayer/issues" }, - "homepage": "https://github.com/zhw2590582/ArtPlayer#readme", - "devDependencies": { - "@babel/core": "^7.1.2", - "@babel/plugin-external-helpers": "^7.0.0", - "@babel/plugin-transform-runtime": "^7.1.0", - "@babel/preset-env": "^7.1.0", - "@babel/runtime": "^7.1.2", - "autoprefixer": "^9.3.1", - "browser-env": "^3.2.5", - "cross-env": "^5.2.0", - "cssnano": "^4.1.7", - "node-sass": "^4.9.4", - "rollup": "^0.67.0", - "rollup-plugin-babel": "^4.0.3", - "rollup-plugin-commonjs": "^9.2.0", - "rollup-plugin-eslint": "^5.0.0", - "rollup-plugin-node-resolve": "^3.4.0", - "rollup-plugin-postcss": "^1.6.2", - "rollup-plugin-replace": "^2.1.0", - "rollup-plugin-svgo": "^1.0.1", - "rollup-plugin-uglify": "^6.0.0" - } + "homepage": "https://github.com/zhw2590582/ArtPlayer#readme" } diff --git a/script/dev.js b/script/dev.js new file mode 100644 index 000000000..e69de29bb diff --git a/script/rollup.config.js b/script/rollup.config.js new file mode 100644 index 000000000..531b188b3 --- /dev/null +++ b/script/rollup.config.js @@ -0,0 +1,63 @@ +const path = require('path'); +const babel = require('rollup-plugin-babel'); +const commonjs = require('rollup-plugin-commonjs'); +const nodeResolve = require('rollup-plugin-node-resolve'); +const postcss = require('rollup-plugin-postcss'); +const { eslint } = require('rollup-plugin-eslint'); +const autoprefixer = require('autoprefixer'); +const cssnano = require('cssnano'); +const replace = require('rollup-plugin-replace'); +const svgo = require('rollup-plugin-svgo'); +const { uglify } = require('rollup-plugin-uglify'); +const { version, homepage, name } = require('./package.json'); + +const isProd = process.env.NODE_ENV === 'production'; + +const banner = + '/*!\n' + + ` * ${name}.js v${version}\n` + + ` * Github: ${homepage}\n` + + ` * (c) 2017-${new Date().getFullYear()} Harvey Zack\n` + + ' * Released under the MIT License.\n' + + ' */\n'; + +export default { + input: 'src/index.js', + output: { + name, + file: isProd ? `dist/${name}.js` : path.join(process.cwd(), '../../', `docs/uncompiled/${name}.js`), + format: 'umd', + exports: 'named', + }, + plugins: [ + eslint({ + exclude: ['node_modules/**', 'src/**/*.scss', 'src/**/*.svg'], + }), + postcss({ + plugins: [autoprefixer, cssnano], + extract: isProd ? `dist/${name}.css` : path.join(process.cwd(), '../../', `docs/uncompiled/${name}.css`), + }), + nodeResolve(), + commonjs(), + babel({ + runtimeHelpers: true, + exclude: 'node_modules/**', + presets: [['@babel/env', { modules: false }]], + plugins: ['@babel/plugin-external-helpers', '@babel/plugin-transform-runtime'], + }), + svgo({ + raw: true, + }), + replace({ + exclude: 'node_modules/**', + __ENV__: JSON.stringify(process.env.NODE_ENV || 'development'), + __VERSION__: version, + }), + isProd && + uglify({ + output: { + preamble: banner, + }, + }), + ], +};