Skip to content

Commit

Permalink
unmount, setup example
Browse files Browse the repository at this point in the history
  • Loading branch information
berndartmueller committed Aug 27, 2020
1 parent c36c0e6 commit c386433
Show file tree
Hide file tree
Showing 9 changed files with 123 additions and 3,881 deletions.
3,720 changes: 0 additions & 3,720 deletions examples/package-lock.json

This file was deleted.

26 changes: 0 additions & 26 deletions examples/package.json

This file was deleted.

4 changes: 2 additions & 2 deletions examples/src/index.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<!DOCTYPE html>
<html lang="en">
<head>
<link rel="stylesheet" href="dist/index.bundle.css" />
<link rel="stylesheet" href="dist/index.css" />
<style>
.image-swiper {
border: 1px solid #ccc;
Expand Down Expand Up @@ -70,6 +70,6 @@
</button>
</div>

<script src="dist/index.bundle.js"></script>
<script src="dist/index.js"></script>
</body>
</html>
2 changes: 2 additions & 0 deletions examples/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import './../../dist/index.css';

import { Virchual } from './../../src/virchual';

[].forEach.call(document.querySelectorAll('.image-swiper'), (slider: HTMLElement) => {
Expand Down
14 changes: 0 additions & 14 deletions examples/tsconfig.json

This file was deleted.

9 changes: 0 additions & 9 deletions examples/tsconfig.webpack.json

This file was deleted.

34 changes: 0 additions & 34 deletions examples/webpack.config.ts

This file was deleted.

186 changes: 110 additions & 76 deletions rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import typescript from 'rollup-plugin-typescript2';
import pkg from './package.json';
import { terser } from 'rollup-plugin-terser';
import serve from 'rollup-plugin-serve';
import { terser } from 'rollup-plugin-terser';
import postcss from 'rollup-plugin-postcss';
import postcss_import from 'postcss-import';
import postcss_copy from 'postcss-copy';
Expand All @@ -10,84 +10,118 @@ import bundleSize from 'rollup-plugin-bundle-size';

const isDevelopment = process.env.NODE_ENV === 'development';

export default {
input: 'src/index.ts', // our source file
output: [
{
file: pkg.main,
format: 'cjs',
},
{
file: pkg.module,
format: 'es', // the preferred format
},
{
file: pkg.browser,
format: 'iife',
name: 'MyPackage', // the global which can be used in a browser,
sourcemap: true,
},
],
external: [...Object.keys(pkg.dependencies || {})],
plugins: [
visualizer(),
typescript({
typescript: require('typescript'),
}),
terser({
compress: {
drop_console: !isDevelopment,
keep_fargs: false,
passes: 2,
export default [
// library
{
input: 'src/index.ts', // our source file
output: [
{
file: pkg.main,
format: 'cjs',
},
keep_fnames: false,
ecma: 6,
mangle: {
properties: true,
toplevel: true,
{
file: pkg.module,
format: 'es', // the preferred format
},
}), // minifies generated bundles
bundleSize(),
postcss({
plugins: [
postcss_import({}),
postcss_copy({
basePath: './src/css',
preservePath: true,
dest: 'dist',
template: 'css/styles.[ext]',
}),

// postcss_url(),
// postcss_url({
// url: "copy",
// basePath: path.resolve("."),
// assetPath: "resources"
// })
],
// Save it to a .css file - we'll reference it ourselves thank you
// very much
extract: true,
sourceMap: true,
//minimize: true, // Causes an error at the moment for some reason
}),
isDevelopment &&
serve({
open: true,

host: '0.0.0.0',
{
file: pkg.browser,
format: 'iife',
name: 'MyPackage', // the global which can be used in a browser,
sourcemap: true,
},
],
plugins: [
visualizer(),
typescript({
typescript: require('typescript'),
}),
terser({
compress: {
drop_console: !isDevelopment,
keep_fargs: false,
passes: 2,
},
keep_fnames: false,
ecma: 6,
mangle: {
properties: true,
toplevel: true,
},
}), // minifies generated bundles
bundleSize(),
postcss({
plugins: [
postcss_import({}),
postcss_copy({
basePath: './src/css',
preservePath: true,
dest: 'dist',
template: 'css/styles.[ext]',
}),

// Page to navigate to when opening the browser.
// Will not do anything if open=false.
// Remember to start with a slash.
openPage: '/index.html',
// postcss_url(),
// postcss_url({
// url: "copy",
// basePath: path.resolve("."),
// assetPath: "resources"
// })
],
// Save it to a .css file - we'll reference it ourselves thank you
// very much
extract: true,
sourceMap: true,
//minimize: true, // Causes an error at the moment for some reason
}),
],
},

// Multiple folders to serve from
contentBase: ['dist', 'examples'],
// example
{
input: './examples/src/index.ts', // our source file
output: [
{
file: './examples/dist/index.js',
format: 'iife',
name: 'virchual', // the global which can be used in a browser,
sourcemap: true,
},
],
plugins: [
typescript({
typescript: require('typescript'),
}),
postcss({
plugins: [
postcss_import({}),
postcss_copy({
basePath: './src/css',
preservePath: true,
dest: 'dist',
template: 'css/styles.[ext]',
}),

// Options used in setting up server
host: 'localhost',
port: 1337,
// postcss_url(),
// postcss_url({
// url: "copy",
// basePath: path.resolve("."),
// assetPath: "resources"
// })
],
// Save it to a .css file - we'll reference it ourselves thank you
// very much
extract: true,
sourceMap: true,
//minimize: true, // Causes an error at the moment for some reason
}),
],
};
isDevelopment &&
serve({
open: true,
host: '0.0.0.0',
openPage: '/index.html',
contentBase: ['./examples/src', './examples'],
host: 'localhost',
port: 1337,
}),
],
},
];
9 changes: 9 additions & 0 deletions src/virchual.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,15 @@ export class Virchual {
this.mountAndUnmountSlides();
}

/**
* Unmount components and cleanup events.
*/
unmount() {
this.eventBus.destroy();

this.eventBus.emit('unmounted');
}

/**
* Register callback fired on the given event(s).
*
Expand Down

0 comments on commit c386433

Please sign in to comment.