-
Notifications
You must be signed in to change notification settings - Fork 97
/
rollup.config.js
38 lines (37 loc) · 1.28 KB
/
rollup.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import alias from '@rollup/plugin-alias';
import resolve from '@rollup/plugin-node-resolve';
import commonjs from '@rollup/plugin-commonjs';
import typescript from 'rollup-plugin-typescript';
export default [
// CommonJS build
{
input: 'src/index.ts',
plugins: [resolve(), commonjs(), typescript()],
external: ['prettier', 'svelte/compiler'],
output: {
file: 'plugin.js',
format: 'cjs',
sourcemap: true,
},
},
// Browser build
// Supported use case: importing the plugin from a bundler like Vite or Webpack
// Semi-supported use case: importing the plugin directly in the browser through using import maps.
// (semi-supported because it requires a svelte/compiler.cjs import map and the .cjs ending has the wrong mime type on CDNs)
{
input: 'src/index.ts',
plugins: [
alias({
entries: [{ find: 'prettier', replacement: 'prettier/standalone' }],
}),
resolve(),
commonjs(),
typescript(),
],
external: ['prettier/standalone', 'prettier/plugins/babel', 'svelte/compiler'],
output: {
file: 'browser.js',
format: 'esm',
},
},
];