Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 7e5a8d8

Browse files
author
eudangeld
committedMay 31, 2020
first build
1 parent 5d34dba commit 7e5a8d8

File tree

3 files changed

+61
-55
lines changed

3 files changed

+61
-55
lines changed
 

‎rollup.config.js

Lines changed: 51 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -2,70 +2,67 @@ import svelte from 'rollup-plugin-svelte';
22
import resolve from '@rollup/plugin-node-resolve';
33
import commonjs from '@rollup/plugin-commonjs';
44
import livereload from 'rollup-plugin-livereload';
5-
import { terser } from 'rollup-plugin-terser';
5+
import {
6+
terser
7+
} from 'rollup-plugin-terser';
68

79
const production = !process.env.ROLLUP_WATCH;
810

911
export default {
10-
input: 'src/main.js',
11-
output: {
12-
sourcemap: true,
13-
format: 'iife',
14-
name: 'app',
15-
file: 'public/build/bundle.js'
16-
},
17-
plugins: [
18-
svelte({
19-
// enable run-time checks when not in production
20-
dev: !production,
21-
// we'll extract any component CSS out into
22-
// a separate file - better for performance
23-
css: css => {
24-
css.write('public/build/bundle.css');
25-
}
26-
}),
12+
input: 'src/main.js',
13+
output: {
14+
sourcemap: true,
15+
format: 'iife',
16+
name: 'app',
17+
file: 'public/build/bundle.js'
18+
},
19+
plugins: [
20+
svelte({
21+
customElement: true,
22+
dev: !production,
23+
}),
2724

28-
// If you have external dependencies installed from
29-
// npm, you'll most likely need these plugins. In
30-
// some cases you'll need additional configuration -
31-
// consult the documentation for details:
32-
// https://github.com/rollup/plugins/tree/master/packages/commonjs
33-
resolve({
34-
browser: true,
35-
dedupe: ['svelte']
36-
}),
37-
commonjs(),
25+
// If you have external dependencies installed from
26+
// npm, you'll most likely need these plugins. In
27+
// some cases you'll need additional configuration -
28+
// consult the documentation for details:
29+
// https://github.com/rollup/plugins/tree/master/packages/commonjs
30+
resolve({
31+
browser: true,
32+
dedupe: ['svelte']
33+
}),
34+
commonjs(),
3835

39-
// In dev mode, call `npm run start` once
40-
// the bundle has been generated
41-
!production && serve(),
36+
// In dev mode, call `npm run start` once
37+
// the bundle has been generated
38+
!production && serve(),
4239

43-
// Watch the `public` directory and refresh the
44-
// browser on changes when not in production
45-
!production && livereload('public'),
40+
// Watch the `public` directory and refresh the
41+
// browser on changes when not in production
42+
!production && livereload('public'),
4643

47-
// If we're building for production (npm run build
48-
// instead of npm run dev), minify
49-
production && terser()
50-
],
51-
watch: {
52-
clearScreen: false
53-
}
44+
// If we're building for production (npm run build
45+
// instead of npm run dev), minify
46+
production && terser()
47+
],
48+
watch: {
49+
clearScreen: false
50+
}
5451
};
5552

5653
function serve() {
57-
let started = false;
54+
let started = false;
5855

59-
return {
60-
writeBundle() {
61-
if (!started) {
62-
started = true;
56+
return {
57+
writeBundle() {
58+
if (!started) {
59+
started = true;
6360

64-
require('child_process').spawn('npm', ['run', 'start', '--', '--dev'], {
65-
stdio: ['ignore', 'inherit', 'inherit'],
66-
shell: true
67-
});
68-
}
69-
}
70-
};
71-
}
61+
require('child_process').spawn('npm', ['run', 'start', '--', '--dev'], {
62+
stdio: ['ignore', 'inherit', 'inherit'],
63+
shell: true
64+
});
65+
}
66+
}
67+
};
68+
}

‎src/main.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import App from './App.svelte';
1+
import App from './micro.svelte';
22

33
const app = new App({
44
target: document.body

‎src/App.svelte renamed to ‎src/micro.svelte

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
<script>
22
let count = 0;
3+
4+
addEventListener("increment", e => increment(), false);
5+
6+
function dispatchIncrment() {
7+
window.dispatchEvent(new CustomEvent("svelte", { detail: "micro-svelte" }));
8+
// window.postMessage("increment", "*");
9+
}
310
function increment() {
411
count += 1;
512
}
@@ -17,6 +24,8 @@
1724
}
1825
</style>
1926

27+
<svelte:options tag="svelte-micro" immutable={true} />
2028
<button on:click={increment}>INCREMENTAR</button>
2129
<p class={count > 0 ? 'positiVo' : 'negaAtiva'}>{count}</p>
2230
<button on:click={decrement}>DECREMENTAR</button>
31+
<button on:click={dispatchIncrment}>dispatchEvent</button>

0 commit comments

Comments
 (0)
Please sign in to comment.