From fc1da90c7e6cc92b66c040480178207ca81097a6 Mon Sep 17 00:00:00 2001
From: David Trattnig <david@subsquare.at>
Date: Fri, 16 Dec 2022 11:56:36 +0100
Subject: [PATCH] chore: add JSON import plugin

---
 rollup.config.js | 279 ++++++++++++++++++++++++-----------------------
 1 file changed, 143 insertions(+), 136 deletions(-)

diff --git a/rollup.config.js b/rollup.config.js
index 16f64f1..6276220 100644
--- a/rollup.config.js
+++ b/rollup.config.js
@@ -1,143 +1,150 @@
-import svelte from 'rollup-plugin-svelte';
-import sveltePreprocess from 'svelte-preprocess';
-import typescript from "@rollup/plugin-typescript";
-import commonjs from '@rollup/plugin-commonjs';
-import resolve from '@rollup/plugin-node-resolve';
-import livereload from 'rollup-plugin-livereload';
-import { terser } from 'rollup-plugin-terser';
-import postcss from 'rollup-plugin-postcss';
-import replace from '@rollup/plugin-replace';
-import pkg from "./package.json";
-
-
-const production = !process.env.ROLLUP_WATCH;
+import commonjs from '@rollup/plugin-commonjs'
+import json from '@rollup/plugin-json'
+import resolve from '@rollup/plugin-node-resolve'
+import replace from '@rollup/plugin-replace'
+import typescript from '@rollup/plugin-typescript'
+import livereload from 'rollup-plugin-livereload'
+import postcss from 'rollup-plugin-postcss'
+import svelte from 'rollup-plugin-svelte'
+import { terser } from 'rollup-plugin-terser'
+import sveltePreprocess from 'svelte-preprocess'
+import pkg from './package.json'
+
+const production = !process.env.ROLLUP_WATCH
 
 function serve() {
-	let server;
-
-	function toExit() {
-		if (server) server.kill(0);
-	}
-
-	return {
-		writeBundle() {
-			if (server) return;
-			server = require('child_process').spawn('npm', ['run', 'start', '--', '--dev'], {
-				stdio: ['ignore', 'inherit', 'inherit'],
-				shell: true
-			});
-
-			process.on('SIGTERM', toExit);
-			process.on('exit', toExit);
-		}
-	};
+  let server
+
+  function toExit() {
+    if (server) server.kill(0)
+  }
+
+  return {
+    writeBundle() {
+      if (server) return
+      server = require('child_process').spawn(
+        'npm',
+        ['run', 'start', '--', '--dev'],
+        {
+          stdio: ['ignore', 'inherit', 'inherit'],
+          shell: true,
+        },
+      )
+
+      process.on('SIGTERM', toExit)
+      process.on('exit', toExit)
+    },
+  }
 }
 
 export default {
-	input: 'src/main.ts',
-	output: {
-		sourcemap: true,
-		format: 'iife',
-		name: 'app',
-		file: 'public/build/aura-player-bundle.js'
-	},
-	plugins: [
-		/** Inject App Version **/
-		replace({
-			preventAssignment: true,
-			APP_VERSION: pkg.version
-		}),
-
-		/** Handle HTML5 Web Components **/
-		svelte({
-			include: /\.wc\.svelte$/,
-			preprocess: sveltePreprocess({
-				sourceMap: !production,
-			}),
-			compilerOptions: {
-				// enable run-time checks when not in production
-				dev: !production,
-				customElement: true,
-			},
-			// store CSS in JavaScript
-			emitCss: false
-		}),
-
-		/** Handle Svelte Components **/
-		svelte({
-			exclude: /\.wc\.svelte$/,
-			preprocess: sveltePreprocess({
-				sourceMap: !production,
-			}),
-			compilerOptions: {
-				// enable run-time checks when not in production
-				dev: !production,
-				customElement: false,
-			},
-			// we'll extract any component CSS out into
-			// a separate file - better for performance
-			emitCss: true
-		}),
-
-		// we'll extract any component CSS out into
-		// a separate file - better for performance
-		// css({ output: 'aura-player-bundle.css' })
-
-		/** SASS Support */
-		postcss({
-			extract: true,
-			minimize: production,
-			use: [
-			  [
-				'sass',
-				{
-				  includePaths: ['./src', './src/theme', './node_modules'],
-				},
-			  ],
-			],
-		  }),
-
-		// If you have external dependencies installed from
-		// npm, you'll most likely need these plugins. In
-		// some cases you'll need additional configuration -
-		// consult the documentation for details:
-		// https://github.com/rollup/plugins/tree/master/packages/commonjs
-		resolve({
-			browser: true,
-			dedupe: ['svelte']
-		}),
-		commonjs(),
-
-		/** TypeScript Support  */
-		typeCheck(),
-		typescript({ rootDir: './src', sourceMap: !production }),
-
-		// In dev mode, call `npm run start` once
-		// the bundle has been generated
-		!production && serve(),
-
-		// Watch the `public` directory and refresh the
-		// browser on changes when not in production
-		!production && livereload('public'),
-
-		// If we're building for production (npm run build
-		// instead of npm run dev), minify
-		production && terser()
-	],
-	watch: {
-		clearScreen: false
-	}
-};
-
-
+  input: 'src/main.ts',
+  output: {
+    sourcemap: true,
+    format: 'iife',
+    name: 'app',
+    file: 'public/build/aura-player-bundle.js',
+  },
+  plugins: [
+    /** Allow import of JSON Files **/
+    json({
+      compact: true,
+    }),
+
+    /** Inject App Version **/
+    replace({
+      preventAssignment: true,
+      __APP_VERSION__: pkg.version,
+    }),
+
+    /** Handle HTML5 Web Components **/
+    svelte({
+      include: /\.wc\.svelte$/,
+      preprocess: sveltePreprocess({
+        sourceMap: !production,
+      }),
+      compilerOptions: {
+        // enable run-time checks when not in production
+        dev: !production,
+        customElement: true,
+      },
+      // store CSS in JavaScript
+      emitCss: false,
+    }),
+
+    /** Handle Svelte Components **/
+    svelte({
+      exclude: /\.wc\.svelte$/,
+      preprocess: sveltePreprocess({
+        sourceMap: !production,
+      }),
+      compilerOptions: {
+        // enable run-time checks when not in production
+        dev: !production,
+        customElement: false,
+      },
+      // we'll extract any component CSS out into
+      // a separate file - better for performance
+      emitCss: true,
+    }),
+
+    // we'll extract any component CSS out into
+    // a separate file - better for performance
+    // css({ output: 'aura-player-bundle.css' })
+
+    /** SASS Support */
+    postcss({
+      extract: true,
+      minimize: production,
+      use: [
+        [
+          'sass',
+          {
+            includePaths: ['./src', './src/theme', './node_modules'],
+          },
+        ],
+      ],
+    }),
+
+    // If you have external dependencies installed from
+    // npm, you'll most likely need these plugins. In
+    // some cases you'll need additional configuration -
+    // consult the documentation for details:
+    // https://github.com/rollup/plugins/tree/master/packages/commonjs
+    resolve({
+      browser: true,
+      dedupe: ['svelte'],
+    }),
+    commonjs(),
+
+    /** TypeScript Support  */
+    typeCheck(),
+    typescript({ rootDir: './src', sourceMap: !production }),
+
+    // In dev mode, call `npm run start` once
+    // the bundle has been generated
+    !production && serve(),
+
+    // Watch the `public` directory and refresh the
+    // browser on changes when not in production
+    !production && livereload('public'),
+
+    // If we're building for production (npm run build
+    // instead of npm run dev), minify
+    production && terser(),
+  ],
+  watch: {
+    clearScreen: false,
+  },
+}
 
 function typeCheck() {
-	return {
-	  writeBundle() {
-		require('child_process').spawn('svelte-check', {
-		  stdio: ['ignore', 'inherit', 'inherit'],
-		  shell: true
-		});
-	  }
-	}
-  }
\ No newline at end of file
+  return {
+    writeBundle() {
+      require('child_process').spawn('svelte-check', {
+        stdio: ['ignore', 'inherit', 'inherit'],
+        shell: true,
+      })
+    },
+  }
+}
-- 
GitLab