From 0d2479f5f186ff5367d4d15e86ff329daab4bbda Mon Sep 17 00:00:00 2001 From: Yanzhen Yu Date: Tue, 23 Oct 2018 19:00:21 +0800 Subject: [PATCH] bundle player as an component --- .eslintrc.json | 5 +++-- .gitignore | 2 ++ package.json | 24 ++++++++++++++++++++++-- public/index.html | 23 +++++++++++++++++------ rollup.config.js | 20 +++++++++++--------- 5 files changed, 55 insertions(+), 19 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index b066720d..263f8d87 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -1,13 +1,14 @@ { "extends": "google", "parserOptions": { - "ecmaVersion": 7, + "ecmaVersion": 8, "sourceType": "module" }, "rules": { "require-jsdoc": "off", "arrow-parens": "off", - "object-curly-spacing": "off" + "object-curly-spacing": "off", + "indent": "off" }, "plugins": ["html"] } diff --git a/.gitignore b/.gitignore index 7be014c5..33f3a2b4 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,5 @@ yarn.lock .vscode temp + +dist diff --git a/package.json b/package.json index c3d94cf6..cdf5d8cc 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "rrweb-player", - "version": "0.1.0", + "version": "0.2.0", "devDependencies": { "eslint": "^5.7.0", "eslint-config-google": "^0.11.0", @@ -19,9 +19,29 @@ }, "scripts": { "build": "rollup -c", + "prepublishOnly": "npm run build", "autobuild": "rollup -c -w", "dev": "run-p start:dev autobuild", "start": "sirv public", "start:dev": "sirv public --dev" - } + }, + "description": "rrweb's replayer UI", + "main": "dist/index.js", + "module": "dist/index.mjs", + "files": [ + "dist" + ], + "repository": { + "type": "git", + "url": "git+https://github.com/rrweb-io/rrweb-player.git" + }, + "keywords": [ + "rrweb" + ], + "author": "yanzhen@smartx.com", + "license": "MIT", + "bugs": { + "url": "https://github.com/rrweb-io/rrweb-player/issues" + }, + "homepage": "https://github.com/rrweb-io/rrweb-player#readme" } diff --git a/public/index.html b/public/index.html index 6bb5adc0..cf5165fb 100644 --- a/public/index.html +++ b/public/index.html @@ -1,16 +1,27 @@ + - - + + - Svelte app + dev panel - - + + - + + + + \ No newline at end of file diff --git a/rollup.config.js b/rollup.config.js index e48c8da1..85fe0bfe 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -2,19 +2,20 @@ import svelte from 'rollup-plugin-svelte'; import resolve from 'rollup-plugin-node-resolve'; import commonjs from 'rollup-plugin-commonjs'; import { terser } from 'rollup-plugin-terser'; +import pkg from './package.json'; const production = !process.env.ROLLUP_WATCH; -export default { - input: 'src/main.js', - output: { - sourcemap: true, - format: 'iife', - name: 'app', - file: 'public/bundle.js', - }, +export default [ + { file: pkg.module, format: 'es' }, + { file: pkg.main, format: 'iife', name: 'rrwebPlayer' }, + { file: 'public/bundle.js', format: 'iife', name: 'rrwebPlayer' }, +].map(output => ({ + input: 'src/Player.html', + output, plugins: [ svelte({ + cascade: false, // opt in to v3 behaviour today skipIntroByDefault: true, nestedTransitions: true, @@ -24,6 +25,7 @@ export default { // we'll extract any component CSS out into // a separate file — better for performance css: css => { + css.write('dist/style.css'); css.write('public/bundle.css'); }, }), @@ -40,4 +42,4 @@ export default { // instead of npm run dev), minify production && terser(), ], -}; +}));