xyc
2025-02-21 664db98c9e8595ce4dd636a27f480e3a08b81ff5
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
/* eslint-env node */
import babel from 'rollup-plugin-babel';
import replace from 'rollup-plugin-re';
 
const plugins = [
  replace({
    patterns: [
      {
        match: /svgedit-config-es\.js/,
        test: 'svgedit-config-es.js',
        replace: 'svgedit-config-iife.js'
      },
      {
        match: /svgedit-config-es\.js/,
        test: "import svgEditor from './editor/svg-editor.js';", // Sets `svgEditor` global for extensions/locales
        replace: `import svgEditor from './editor/svg-editor.js';
window.svgEditor = svgEditor;
window.svgEditor.modules = false;
        `
      },
      {
        match: /xdomain-svgedit-config-es\.js/,
        test: "import svgEditor from './svg-editor.js';",
        replace: `import svgEditor from './svg-editor.js';
window.svgEditor = svgEditor;
window.svgEditor.modules = false;
`
      }
    ]
  }),
  babel({
    plugins: ['transform-object-rest-spread']
  })
];
 
export default [
  {
    input: 'svgedit-config-es.js',
    output: {
      format: 'iife',
      file: `svgedit-config-iife.js`
    },
    plugins
  },
  {
    input: 'editor/xdomain-svgedit-config-es.js',
    output: {
      format: 'iife',
      file: `editor/xdomain-svgedit-config-iife.js`
    },
    plugins
  }
];