@@ -3,51 +3,62 @@ import resolve from "rollup-plugin-node-resolve";
3
3
import commonjs from "rollup-plugin-commonjs" ;
4
4
import livereload from "rollup-plugin-livereload" ;
5
5
import { terser } from "rollup-plugin-terser" ;
6
+ import typescript from "@rollup/plugin-typescript" ;
7
+ import autoPreprocess from "svelte-preprocess" ;
8
+ import svelteDts from "svelte-dts" ;
6
9
import pkg from "./package.json" ;
7
10
8
11
const production = ! process . env . ROLLUP_WATCH ;
9
12
10
13
export default [
11
14
{
12
- input : "src/dev/main.js " ,
15
+ input : "src/dev/main.ts " ,
13
16
output : {
14
17
sourcemap : true ,
15
18
format : "iife" ,
16
19
name : "app" ,
17
- file : "public/build/bundle.js"
20
+ file : "public/build/bundle.js" ,
18
21
} ,
19
22
plugins : [
20
23
svelte ( {
21
24
dev : ! production ,
22
- css : css => {
23
- css . write ( "public/build/bundle.css" ) ;
24
- }
25
+ css : ( css ) => css . write ( "bundle.css" ) ,
26
+ preprocess : autoPreprocess ( ) ,
25
27
} ) ,
28
+ typescript ( { sourceMap : ! production } ) ,
26
29
resolve ( {
27
30
browser : true ,
28
- dedupe : importee =>
29
- importee === "svelte" || importee . startsWith ( "svelte/" )
31
+ dedupe : ( importee ) =>
32
+ importee === "svelte" || importee . startsWith ( "svelte/" ) ,
30
33
} ) ,
31
34
commonjs ( ) ,
32
35
! production && serve ( ) ,
33
36
! production && livereload ( "public" ) ,
34
- production && terser ( )
37
+ production && terser ( ) ,
35
38
] ,
36
- watch : {
37
- clearScreen : false
38
- }
39
+ watch : { clearScreen : false } ,
39
40
} ,
40
41
{
41
42
input : "src/lib/InfiniteScroll.svelte" ,
42
43
output : { file : pkg . main , format : "umd" , name : "InfiniteScroll" } ,
43
- plugins : [ svelte ( ) , resolve ( ) , commonjs ( ) ]
44
+ plugins : [
45
+ svelte ( { preprocess : autoPreprocess ( ) } ) ,
46
+ typescript ( { sourceMap : ! production } ) ,
47
+ resolve ( ) ,
48
+ commonjs ( ) ,
49
+ ] ,
44
50
} ,
45
51
{
46
52
input : "src/lib/InfiniteScroll.svelte" ,
47
53
output : { file : pkg . module , format : "es" } ,
48
54
external : [ "svelte/internal" ] ,
49
- plugins : [ svelte ( ) , commonjs ( ) ]
50
- }
55
+ plugins : [
56
+ svelteDts ( { output : pkg . types } ) ,
57
+ svelte ( { preprocess : autoPreprocess ( ) } ) ,
58
+ typescript ( { sourceMap : ! production } ) ,
59
+ commonjs ( ) ,
60
+ ] ,
61
+ } ,
51
62
] ;
52
63
53
64
function serve ( ) {
@@ -60,9 +71,9 @@ function serve() {
60
71
61
72
require ( "child_process" ) . spawn ( "npm" , [ "run" , "start" , "--" , "--dev" ] , {
62
73
stdio : [ "ignore" , "inherit" , "inherit" ] ,
63
- shell : true
74
+ shell : true ,
64
75
} ) ;
65
76
}
66
- }
77
+ } ,
67
78
} ;
68
79
}
0 commit comments