@zipify/wysiwyg 3.5.0-2 → 3.5.0-3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -5,6 +5,7 @@ import commonjs from '@rollup/plugin-commonjs';
5
5
  import replace from '@rollup/plugin-replace';
6
6
  import json from '@rollup/plugin-json';
7
7
  import { resolvePath, isDevelopment } from './settings';
8
+ import { svg } from './plugins/svg';
8
9
 
9
10
  const productionPlugins = isDevelopment ? [] : [
10
11
  terser({ toplevel: true })
@@ -27,6 +28,7 @@ export default {
27
28
  },
28
29
 
29
30
  plugins: [
31
+ svg(),
30
32
  replace({
31
33
  preventAssignment: true,
32
34
  values: { 'import.meta.glob': '(() => ({}))' }
@@ -1,6 +1,7 @@
1
1
  import { defineConfig } from 'vite';
2
2
  import { createVuePlugin } from 'vite-plugin-vue2';
3
3
  import { resolvePath } from './settings';
4
+ import { svg } from './plugins/svg';
4
5
 
5
6
  export default defineConfig({
6
7
  root: resolvePath('./example'),
@@ -17,7 +18,7 @@ export default defineConfig({
17
18
  extensions: ['*', '.js', '.vue', '.json']
18
19
  },
19
20
 
20
- plugins: [createVuePlugin()],
21
+ plugins: [createVuePlugin(), svg()],
21
22
 
22
23
  define: {
23
24
  ZW_UPDATED_AT: Date.now()
@@ -2,6 +2,7 @@ import { defineConfig } from 'vite';
2
2
  import { createVuePlugin } from 'vite-plugin-vue2';
3
3
  import { optimizeLodashImports } from '@optimize-lodash/rollup-plugin';
4
4
  import { resolvePath } from './settings';
5
+ import { svg } from './plugins/svg';
5
6
 
6
7
  export default defineConfig({
7
8
  build: {
@@ -29,6 +30,7 @@ export default defineConfig({
29
30
 
30
31
  plugins: [
31
32
  createVuePlugin(),
32
- optimizeLodashImports()
33
+ optimizeLodashImports(),
34
+ svg()
33
35
  ]
34
36
  });
@@ -0,0 +1,25 @@
1
+ import fs from 'fs/promises';
2
+ import { extname } from 'path';
3
+
4
+ export function svg(options = {}) {
5
+ return {
6
+ name: 'rawsvg',
7
+
8
+ async transform(code, id) {
9
+ if (extname(id) !== '.svg') {
10
+ return null;
11
+ }
12
+
13
+ let content;
14
+
15
+ try {
16
+ content = await fs.readFile(id, 'utf-8');
17
+ } catch (ex) {
18
+ // eslint-disable-next-line no-console
19
+ console.warn('\n', `${id} couldn't be loaded, fallback to default loader`);
20
+ return;
21
+ }
22
+ return { code: `export default ${JSON.stringify(content)}`, map: { mappings: '' } };
23
+ }
24
+ };
25
+ }