Showing
3 changed files
with
55 additions
and
61 deletions
This diff is collapsed. Click to expand it.
... | @@ -10,7 +10,6 @@ | ... | @@ -10,7 +10,6 @@ |
10 | "@rollup/plugin-commonjs": "11.0.2", | 10 | "@rollup/plugin-commonjs": "11.0.2", |
11 | "@rollup/plugin-node-resolve": "^7.0.0", | 11 | "@rollup/plugin-node-resolve": "^7.0.0", |
12 | "rollup": "^1.20.0", | 12 | "rollup": "^1.20.0", |
13 | - "rollup-plugin-livereload": "^1.0.0", | ||
14 | "rollup-plugin-svelte": "^5.0.3", | 13 | "rollup-plugin-svelte": "^5.0.3", |
15 | "rollup-plugin-terser": "^5.1.2", | 14 | "rollup-plugin-terser": "^5.1.2", |
16 | "svelte": "^3.0.0" | 15 | "svelte": "^3.0.0" | ... | ... |
1 | import svelte from 'rollup-plugin-svelte'; | 1 | import svelte from 'rollup-plugin-svelte'; |
2 | import resolve from '@rollup/plugin-node-resolve'; | 2 | import resolve from '@rollup/plugin-node-resolve'; |
3 | import commonjs from '@rollup/plugin-commonjs'; | 3 | import commonjs from '@rollup/plugin-commonjs'; |
4 | -import livereload from 'rollup-plugin-livereload'; | ||
5 | import { terser } from 'rollup-plugin-terser'; | 4 | import { terser } from 'rollup-plugin-terser'; |
6 | import copy from 'rollup-plugin-copy'; | 5 | import copy from 'rollup-plugin-copy'; |
7 | 6 | ||
8 | const production = !process.env.ROLLUP_WATCH; | 7 | const production = !process.env.ROLLUP_WATCH; |
9 | 8 | ||
10 | export default { | 9 | export default { |
11 | - input: 'src/main.js', | 10 | + input: 'src/main.js', |
12 | - output: { | 11 | + output: { |
13 | - sourcemap: true, | 12 | + sourcemap: true, |
14 | - format: 'iife', | 13 | + format: 'iife', |
15 | - name: 'app', | 14 | + name: 'app', |
16 | - file: 'public/build/bundle.js' | 15 | + file: 'public/build/bundle.js' |
17 | - }, | 16 | + }, |
18 | - plugins: [ | 17 | + plugins: [ |
19 | - svelte({ | 18 | + svelte({ |
20 | - // enable run-time checks when not in production | 19 | + // enable run-time checks when not in production |
21 | - dev: !production, | 20 | + dev: !production, |
22 | - // we'll extract any component CSS out into | 21 | + // we'll extract any component CSS out into |
23 | - // a separate file - better for performance | 22 | + // a separate file - better for performance |
24 | - css: css => { | 23 | + css: css => { |
25 | - css.write('public/build/bundle.css'); | 24 | + css.write('public/build/bundle.css'); |
26 | - } | 25 | + } |
27 | - }), | 26 | + }), |
28 | 27 | ||
29 | - // If you have external dependencies installed from | 28 | + // If you have external dependencies installed from |
30 | - // npm, you'll most likely need these plugins. In | 29 | + // npm, you'll most likely need these plugins. In |
31 | - // some cases you'll need additional configuration - | 30 | + // some cases you'll need additional configuration - |
32 | - // consult the documentation for details: | 31 | + // consult the documentation for details: |
33 | - // https://github.com/rollup/plugins/tree/master/packages/commonjs | 32 | + // https://github.com/rollup/plugins/tree/master/packages/commonjs |
34 | - resolve({ | 33 | + resolve({ |
35 | - browser: true, | 34 | + browser: true, |
36 | - dedupe: ['svelte'] | 35 | + dedupe: ['svelte'] |
37 | - }), | 36 | + }), |
38 | - commonjs(), | 37 | + commonjs(), |
39 | 38 | ||
40 | - copy({ | 39 | + copy({ |
41 | - targets:[ | 40 | + targets: [ |
42 | - { src:'src/images', dest:'public' } | 41 | + { src: 'src/images', dest: 'public' } |
43 | - ] | 42 | + ] |
44 | - }), | 43 | + }), |
45 | 44 | ||
46 | - // In dev mode, call `npm run start` once | 45 | + // In dev mode, call `npm run start` once |
47 | - // the bundle has been generated | 46 | + // the bundle has been generated |
48 | - !production && serve(), | 47 | + !production && serve(), |
49 | 48 | ||
50 | - // Watch the `public` directory and refresh the | 49 | + // If we're building for production (npm run build |
51 | - // browser on changes when not in production | 50 | + // instead of npm run dev), minify |
52 | - !production && livereload('public'), | 51 | + production && terser() |
53 | - | 52 | + ], |
54 | - // If we're building for production (npm run build | 53 | + watch: { |
55 | - // instead of npm run dev), minify | 54 | + clearScreen: false |
56 | - production && terser() | 55 | + } |
57 | - ], | ||
58 | - watch: { | ||
59 | - clearScreen: false | ||
60 | - } | ||
61 | }; | 56 | }; |
62 | 57 | ||
63 | function serve() { | 58 | function serve() { |
64 | - let started = false; | 59 | + let started = false; |
65 | 60 | ||
66 | - return { | 61 | + return { |
67 | - writeBundle() { | 62 | + writeBundle() { |
68 | - if (!started) { | 63 | + if (!started) { |
69 | - started = true; | 64 | + started = true; |
70 | 65 | ||
71 | - require('child_process').spawn('npm', ['run', 'start', '--', '--dev'], { | 66 | + require('child_process').spawn('npm', ['run', 'start', '--', '--dev'], { |
72 | - stdio: ['ignore', 'inherit', 'inherit'], | 67 | + stdio: ['ignore', 'inherit', 'inherit'], |
73 | - shell: true | 68 | + shell: true |
74 | - }); | 69 | + }); |
75 | - } | 70 | + } |
76 | - } | 71 | + } |
77 | - }; | 72 | + }; |
78 | -} | 73 | +} |
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
-
Please register or login to post a comment