diff --git a/.prettierignore b/.prettierignore
index 1521c8b..a60030e 100644
--- a/.prettierignore
+++ b/.prettierignore
@@ -1 +1,2 @@
-dist
+dist/
+coverage/
diff --git a/README.md b/README.md
index f2f38c6..050fc39 100644
--- a/README.md
+++ b/README.md
@@ -228,9 +228,9 @@ npm run test
### Unit
-Jest is used for unit-tests.
+Vitest is used for unit-tests.
-[`Jest`](https://jestjs.io) and [`VueTestUtils`](https://vue-test-utils.vuejs.org) is used for unit tests.
+[`Vitest`](https://vitest.dev/) and [`VueTestUtils`](https://test-utils.vuejs.org) are used for unit tests.
You can run unit tests by running the next command:
@@ -267,8 +267,8 @@ To build the production ready bundle simply run `npm run build`:
After the successful build the following files will be generated in the `dist` folder:
```
-├── vue-lazy-youtube-video.common.js
-├── vue-lazy-youtube-video.esm.js
+├── vue-lazy-youtube-video.cjs.js
+├── vue-lazy-youtube-video.mjs
├── vue-lazy-youtube-video.js
├── vue-lazy-youtube-video.min.js
├── style.css
@@ -280,10 +280,9 @@ After the successful build the following files will be generated in the `dist` f
## Powered by
- [`Vue`](https://vuejs.org)
-- [`Rollup`](https://rollupjs.org/guide/en) (and plugins)
-- [`Babel`](https://babeljs.io)
-- [`Jest`](https://jestjs.io)
-- [`Vue Test Utils`](http://vue-test-utils.vuejs.org)
+- [`Vite`](https://vitejs.dev/) (and plugins)
+- [`Vitest`](https://vitest.dev/)
+- [`Vue Test Utils`](https://test-utils.vuejs.org/)
- [`TypeScript`](http://www.typescriptlang.org)
- [`PostCSS`](https://postcss.org)
diff --git a/build/base/plugins/index.js b/build/base/plugins/index.js
deleted file mode 100644
index 0e93f64..0000000
--- a/build/base/plugins/index.js
+++ /dev/null
@@ -1,7 +0,0 @@
-import common from '@rollup/plugin-commonjs'
-import resolve from '@rollup/plugin-node-resolve'
-
-/** @type {import('rollup').RollupOptions['plugins']} */
-const plugins = [common(), resolve()]
-
-export default plugins
diff --git a/build/rollup.config.dev.js b/build/rollup.config.dev.js
deleted file mode 100644
index 9ed2cd6..0000000
--- a/build/rollup.config.dev.js
+++ /dev/null
@@ -1,38 +0,0 @@
-import path from 'path'
-import { defineConfig } from 'rollup'
-import typescript from '@rollup/plugin-typescript'
-import serve from 'rollup-plugin-serve'
-import livereload from 'rollup-plugin-livereload'
-import replace from '@rollup/plugin-replace'
-import css from 'rollup-plugin-css-only'
-
-import plugins from './base/plugins/index'
-
-const DEMO_DIR = path.join(__dirname, '../demo')
-
-export default defineConfig({
- input: path.join(DEMO_DIR, 'index.ts'),
- output: {
- file: path.join(DEMO_DIR, 'demo.js'),
- format: 'iife',
- name: 'demo',
- sourcemap: true,
- },
- plugins: [
- typescript(),
- css(),
- replace({
- 'process.env.NODE_ENV': JSON.stringify('development'),
- preventAssignment: true,
- }),
- serve({
- open: true,
- contentBase: DEMO_DIR,
- port: 8080,
- }),
- livereload({
- verbose: true,
- watch: DEMO_DIR,
- }),
- ].concat(plugins),
-})
diff --git a/build/rollup.config.prod.js b/build/rollup.config.prod.js
deleted file mode 100644
index 16aa341..0000000
--- a/build/rollup.config.prod.js
+++ /dev/null
@@ -1,69 +0,0 @@
-import path from 'path'
-import { defineConfig } from 'rollup'
-import typescript from '@rollup/plugin-typescript'
-import replace from '@rollup/plugin-replace'
-import { terser } from 'rollup-plugin-terser'
-
-import basePlugins from './base/plugins/index'
-
-const SOURCE = path.join(__dirname, '../src/index.ts')
-const DIST_DIR = 'dist'
-const FILE_NAME = 'vue-lazy-youtube-video'
-const name = 'VueLazyYoutubeVideo'
-const external = ['vue']
-const globals = {
- vue: 'Vue',
-}
-const plugins = [
- replace({
- 'process.env.NODE_ENV': JSON.stringify('production'),
- preventAssignment: true,
- }),
-].concat(basePlugins)
-
-export default [
- defineConfig({
- input: SOURCE,
- external,
- output: [
- {
- file: `${DIST_DIR}/${FILE_NAME}.js`,
- format: 'umd',
- exports: 'named',
- globals,
- name,
- },
- {
- file: `${DIST_DIR}/${FILE_NAME}.common.js`,
- exports: 'named',
- format: 'cjs',
- },
- {
- file: `${DIST_DIR}/${FILE_NAME}.esm.js`,
- format: 'esm',
- },
- ],
- plugins: [
- typescript({
- tsconfig: './tsconfig.prod.json',
- }),
- ].concat(plugins),
- }),
- defineConfig({
- input: SOURCE,
- external,
- output: {
- file: `${DIST_DIR}/${FILE_NAME}.min.js`,
- format: 'umd',
- exports: 'named',
- globals,
- name,
- },
- plugins: [
- typescript({
- tsconfig: './tsconfig.prod.umd.json',
- }),
- terser({ output: { comments: false } }),
- ].concat(plugins),
- }),
-]
diff --git a/demo/App.ts b/demo/App.ts
deleted file mode 100644
index 02a3c32..0000000
--- a/demo/App.ts
+++ /dev/null
@@ -1,86 +0,0 @@
-import Vue, { VNode } from 'vue'
-
-import { LoadIframeEventPayload } from '../src/types'
-import VueLazyYoutubeVideo from '../src'
-
-export default Vue.extend({
- name: 'AppPage',
- data() {
- return {
- thumbnailListeners: {
- load() {
- console.log('load')
- },
- },
- iframeAttributes: {
- id: 'foo',
- },
- }
- },
- methods: {
- onIframeLoad({ iframe }: LoadIframeEventPayload) {
- console.log(': ', iframe)
- const id = iframe ? iframe.id : this.iframeAttributes.id
- console.log('Resolved id: ', id)
- const player = new YT.Player(id, {})
- console.log('YT.Player instance: ', player)
- setTimeout(() => {
- player.stopVideo()
- }, 3000)
- },
- onPlayerInit(player: YT.Player) {
- console.log(player)
- },
- },
- render(h): VNode {
- return h('ul', {}, [
- h('li', {}, [
- h(VueLazyYoutubeVideo, {
- props: {
- src: 'https://www.youtube.com/embed/4JS70KB9GS0',
- previewImageSize: 'maxresdefault',
- alt: 'foo',
- buttonLabel: 'baz',
- imgListeners: this.thumbnailListeners,
- },
- }),
- ]),
- h('li', {}, [
- h(VueLazyYoutubeVideo, {
- props: {
- src: 'https://www.youtube.com/embed/4JS70KB9GS0',
- aspectRatio: '1:1',
- previewImageSize: 'default',
- parameters: {
- start: 32,
- },
- },
- }),
- ]),
- h('li', {}, [
- h(VueLazyYoutubeVideo, {
- props: {
- src: 'https://www.youtube.com/embed/4JS70KB9GS0',
- thumbnail: { webp: 'foo', jpg: 'bar' },
- },
- }),
- ]),
- h('li', {}, [
- h(VueLazyYoutubeVideo, {
- props: {
- src: 'https://www.youtube.com/embed/4JS70KB9GS0',
- webp: false,
- autoplay: true,
- iframeAttributes: this.iframeAttributes,
- enablejsapi: true,
- injectPlayerScript: true,
- },
- on: {
- 'load:iframe': this.onIframeLoad,
- 'init:player': this.onPlayerInit,
- },
- }),
- ]),
- ])
- },
-})
diff --git a/demo/App.vue b/demo/App.vue
new file mode 100644
index 0000000..391b60e
--- /dev/null
+++ b/demo/App.vue
@@ -0,0 +1,68 @@
+
+
+
+
+
+
diff --git a/demo/index.html b/demo/index.html
index f94f307..13ff6a8 100644
--- a/demo/index.html
+++ b/demo/index.html
@@ -5,12 +5,12 @@
-