2023-02-10 12:23:51 +00:00
|
|
|
import svelte from "rollup-plugin-svelte";
|
|
|
|
|
import sveltePreprocess from "svelte-preprocess";
|
|
|
|
|
import { vitePreprocess } from '@sveltejs/kit/vite';
|
|
|
|
|
import tailwindcss from "tailwindcss";
|
|
|
|
|
import autoprefixer from "autoprefixer";
|
2023-06-05 21:50:16 +00:00
|
|
|
import nodePolyfills from 'rollup-plugin-polyfill-node';
|
2023-02-10 12:23:51 +00:00
|
|
|
import resolve from "@rollup/plugin-node-resolve";
|
|
|
|
|
import commonjs from "@rollup/plugin-commonjs";
|
|
|
|
|
import css from "rollup-plugin-css-only";
|
|
|
|
|
import serve from "rollup-plugin-serve";
|
2023-03-30 18:10:27 +00:00
|
|
|
import json from "@rollup/plugin-json";
|
2023-02-10 12:23:51 +00:00
|
|
|
import livereload from "rollup-plugin-livereload";
|
|
|
|
|
import { terser } from "rollup-plugin-terser";
|
|
|
|
|
import esformatter from "rollup-plugin-esformatter";
|
|
|
|
|
import postcss from "rollup-plugin-postcss";
|
|
|
|
|
|
|
|
|
|
const production = true; //false;// !process.env.ROLLUP_WATCH;
|
|
|
|
|
|
|
|
|
|
export default {
|
|
|
|
|
input: "src/widget.js",
|
|
|
|
|
output: {
|
2023-03-30 18:10:27 +00:00
|
|
|
file: "static/public/bundle.js",
|
2023-02-10 12:23:51 +00:00
|
|
|
format: "iife",
|
|
|
|
|
name: "app",
|
|
|
|
|
sourcemap: production,
|
2023-06-05 21:50:16 +00:00
|
|
|
globals: {
|
|
|
|
|
"https": "https",
|
|
|
|
|
"http": "http",
|
|
|
|
|
"net": "net",
|
|
|
|
|
}
|
|
|
|
|
|
2023-02-10 12:23:51 +00:00
|
|
|
},
|
|
|
|
|
plugins: [
|
|
|
|
|
// compile svelte with tailwindcss as preprocess (including autoprefixer)
|
|
|
|
|
svelte({
|
|
|
|
|
preprocess: [
|
|
|
|
|
sveltePreprocess({
|
|
|
|
|
sourceMap: !production,
|
|
|
|
|
postcss: {
|
|
|
|
|
plugins: [tailwindcss(), autoprefixer()],
|
|
|
|
|
},
|
|
|
|
|
}),
|
|
|
|
|
vitePreprocess(),
|
|
|
|
|
],
|
|
|
|
|
}),
|
|
|
|
|
|
|
|
|
|
// resolve external dependencies from NPM
|
|
|
|
|
resolve({
|
|
|
|
|
browser: true,
|
|
|
|
|
dedupe: ["svelte"],
|
|
|
|
|
preferBuiltins: false
|
|
|
|
|
}),
|
2023-03-30 18:10:27 +00:00
|
|
|
json(),
|
2023-02-10 12:23:51 +00:00
|
|
|
commonjs(),
|
2023-06-05 21:50:16 +00:00
|
|
|
nodePolyfills( /* options */ ),
|
2023-02-10 12:23:51 +00:00
|
|
|
|
|
|
|
|
// export CSS in separate file for better performance
|
|
|
|
|
css({ output: "bundle.css" }),
|
|
|
|
|
// postcss({
|
|
|
|
|
// config: {
|
|
|
|
|
// path: "./postcss.config.js",
|
|
|
|
|
// },
|
|
|
|
|
// extensions: [".css"],
|
|
|
|
|
// minimize: true,
|
|
|
|
|
// inject: {
|
|
|
|
|
// insertAt: "top",
|
|
|
|
|
// },
|
|
|
|
|
// }),
|
|
|
|
|
|
|
|
|
|
// start a local livereload server on public/ folder
|
|
|
|
|
!production && serve("public/"),
|
|
|
|
|
!production && livereload("public/"),
|
|
|
|
|
|
|
|
|
|
// minify bundles in production mode
|
2023-06-05 21:50:16 +00:00
|
|
|
production && terser(),
|
2023-02-10 12:23:51 +00:00
|
|
|
],
|
2023-03-30 18:10:27 +00:00
|
|
|
};
|