diff --git a/docs/uncompiled/artplayer-plugin-subtitle.js b/docs/uncompiled/artplayer-plugin-subtitle.js
index 3693cfbe2..95c2ebaf2 100644
--- a/docs/uncompiled/artplayer-plugin-subtitle.js
+++ b/docs/uncompiled/artplayer-plugin-subtitle.js
@@ -85,4 +85,3 @@
Object.defineProperty(exports, '__esModule', { value: true });
})));
-//# sourceMappingURL=artplayer-plugin-subtitle.js.map
diff --git a/package.json b/package.json
index 7bd2b0907..8353de710 100644
--- a/package.json
+++ b/package.json
@@ -5,8 +5,12 @@
"scripts": {
"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",
+ "dev:artplayer": "cross-env NODE_ENV=development cross-env TARGET=artplayer rollup -w -c scripts/config.js",
+ "dev:artplayer-plugin-danmu": "cross-env NODE_ENV=development cross-env TARGET=artplayer-plugin-danmu rollup -w -c scripts/config.js",
+ "dev:artplayer-plugin-subtitle": "cross-env NODE_ENV=development cross-env TARGET=artplayer-plugin-subtitle rollup -w -c scripts/config.js",
+ "build:artplayer": "cross-env NODE_ENV=production TARGET=artplayer rollup -c scripts/config.js",
+ "build:artplayer-plugin-danmu": "cross-env NODE_ENV=production TARGET=artplayer-plugin-danmu rollup -c scripts/config.js",
+ "build:artplayer-plugin-subtitle": "cross-env NODE_ENV=production TARGET=artplayer-plugin-subtitle rollup -c scripts/config.js",
"test": "node ./node_modules/.bin/mocha-chrome ./docs/test/index.html --mocha '{\"ui\":\"bdd\"}'",
"lint": "node ./node_modules/.bin/eslint packages/*/src"
},
@@ -24,7 +28,7 @@
"url": "https://github.com/zhw2590582/ArtPlayer/issues"
},
"homepage": "https://github.com/zhw2590582/ArtPlayer#readme",
- "devDependencies": {
+ "dependencies": {
"@babel/core": "^7.1.2",
"@babel/plugin-external-helpers": "^7.0.0",
"@babel/plugin-transform-runtime": "^7.1.0",
diff --git a/packages/artplayer-plugin-subtitle/dist/artplayer-plugin-subtitle.js b/packages/artplayer-plugin-subtitle/dist/artplayer-plugin-subtitle.js
index a1511c335..4866d1089 100644
--- a/packages/artplayer-plugin-subtitle/dist/artplayer-plugin-subtitle.js
+++ b/packages/artplayer-plugin-subtitle/dist/artplayer-plugin-subtitle.js
@@ -1,8 +1,8 @@
/*!
- * artplayer-plugin-subtitle.js v1.0.3
+ * artplayer-plugin-subtitle.js v1.0.4
* Github: https://github.com/zhw2590582/ArtPlayer#readme
* (c) 2017-2018 Harvey Zack
* Released under the MIT License.
*/
-!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e(t["artplayer-plugin-subtitle"]={})}(this,function(t){"use strict";function e(i){var t=i.i18n,a=i.events.proxy;return{title:"Subtitle",name:"subtitle",index:20,html:'\n
\n \n \n
\n '),mounted:function(t){var e=t.querySelector(".art-subtitle-range"),n=t.querySelector(".art-subtitle-value");a(e,"change",function(){var t=e.value;n.innerText=t,i.plugins.artplayerPluginSubtitle.set(Number(t))}),i.on("subtitle:switch",function(){e.value=0,n.innerText=0}),i.on("artplayerPluginSubtitle:set",function(t){e.value!==t&&(e.value=t,n.innerText=t)})}}}function n(i){var a=i.constructor.utils.clamp,t=i.setting,r=i.notice,u=i.refs,o=i.i18n;o.update({"zh-cn":{"Subtitle offset time":"字幕偏移时间"},"zh-tw":{"Subtitle offset time":"字幕偏移時間"}}),t.add(e);var s=[];return i.on("subtitle:switch",function(){s=[]}),{set:function(t){var e=Array.from(u.$track.track.cues),n=a(t,-5,5);e.forEach(function(t,e){s[e]||(s[e]={startTime:t.startTime,endTime:t.endTime}),t.startTime=s[e].startTime+n,t.endTime=s[e].endTime+n}),r.show("".concat(o.get("Subtitle offset time"),": ").concat(t,"s")),i.emit("artplayerPluginSubtitle:set",t)}}}window.artplayerPluginSubtitle=n,t.default=n,Object.defineProperty(t,"__esModule",{value:!0})});
+!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e(t["artplayer-plugin-subtitle"]={})}(this,function(t){"use strict";function e(i){var t=i.i18n,a=i.events.proxy;return{title:"Subtitle",name:"subtitle",index:20,html:'\n \n \n \n
\n '),mounted:function(t){var e=t.querySelector(".art-subtitle-range"),n=t.querySelector(".art-subtitle-value");a(e,"change",function(){var t=e.value;n.innerText=t,i.plugins.artplayerPluginSubtitle.offset(Number(t))}),i.on("subtitle:switch",function(){e.value=0,n.innerText=0}),i.on("artplayerPluginSubtitle:set",function(t){e.value!==t&&(e.value=t,n.innerText=t)})}}}function n(i){var a=i.constructor.utils.clamp,t=i.setting,r=i.notice,u=i.template,o=i.i18n;o.update({"zh-cn":{"Subtitle offset time":"字幕偏移时间"},"zh-tw":{"Subtitle offset time":"字幕偏移時間"}}),t.add(e);var l=[];return i.on("subtitle:switch",function(){l=[]}),{offset:function(t){var e=Array.from(u.$track.track.cues),n=a(t,-5,5);e.forEach(function(t,e){l[e]||(l[e]={startTime:t.startTime,endTime:t.endTime}),t.startTime=l[e].startTime+n,t.endTime=l[e].endTime+n}),r.show("".concat(o.get("Subtitle offset time"),": ").concat(t,"s")),i.emit("artplayerPluginSubtitle:set",t)}}}window.artplayerPluginSubtitle=n,t.default=n,Object.defineProperty(t,"__esModule",{value:!0})});
diff --git a/script/dev.js b/script/dev.js
deleted file mode 100644
index e69de29bb..000000000
diff --git a/script/rollup.config.js b/script/rollup.config.js
deleted file mode 100644
index 531b188b3..000000000
--- a/script/rollup.config.js
+++ /dev/null
@@ -1,63 +0,0 @@
-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,
- },
- }),
- ],
-};
diff --git a/scripts/config.js b/scripts/config.js
new file mode 100644
index 000000000..9fed6bdc1
--- /dev/null
+++ b/scripts/config.js
@@ -0,0 +1,70 @@
+const fs = require('fs');
+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');
+
+function creatRollupConfig(target) {
+ const projectPath = path.join(process.cwd(), 'packages', target);
+ console.log(projectPath);
+ const packageJson = JSON.parse(fs.readFileSync(path.join(projectPath, 'package.json'), 'utf-8'));
+ const { version, homepage, name } = packageJson;
+ 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';
+
+ return {
+ input: path.join(projectPath, 'src/index.js'),
+ output: {
+ name,
+ file: isProd ? path.join(projectPath, `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 ? path.join(projectPath, `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,
+ },
+ }),
+ ],
+ };
+};
+
+module.exports = creatRollupConfig(process.env.TARGET);
\ No newline at end of file
diff --git a/script/build.js b/scripts/copyAfterBuild.js
similarity index 100%
rename from script/build.js
rename to scripts/copyAfterBuild.js
diff --git a/scripts/logger.js b/scripts/logger.js
new file mode 100644
index 000000000..021fbd266
--- /dev/null
+++ b/scripts/logger.js
@@ -0,0 +1,27 @@
+const chalk = require('chalk');
+const { format } = require('util');
+
+const prefix = 'artplayer-cli';
+const sep = chalk.gray('·');
+
+exports.log = function log(...args) {
+ const msg = format.apply(format, args);
+ console.log(chalk.white(prefix), sep, msg);
+};
+
+exports.fatal = function fatal(...args) {
+ if (args[0] instanceof Error) args[0] = args[0].message.trim();
+ const msg = format.apply(format, args);
+ console.error(chalk.red(prefix), sep, msg);
+ process.exit(1);
+};
+
+exports.success = function success(...args) {
+ const msg = format.apply(format, args);
+ console.log(chalk.green(prefix), sep, msg);
+};
+
+exports.warn = function warn(...args) {
+ const msg = format.apply(format, args);
+ console.log(chalk.yellow(prefix), sep, msg);
+};