You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
99 lines
2.5 KiB
99 lines
2.5 KiB
import fs from "fs";
|
|
|
|
import svelte from "rollup-plugin-svelte";
|
|
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 sveltePreprocess from "svelte-preprocess";
|
|
import typescript from "@rollup/plugin-typescript";
|
|
import css from "rollup-plugin-css-only";
|
|
import dev from "rollup-plugin-dev";
|
|
import replace from "@rollup/plugin-replace";
|
|
import json from "@rollup/plugin-json";
|
|
|
|
const production = !process.env.ROLLUP_WATCH;
|
|
const envVariables = fs.readFileSync("build.env", "utf-8")
|
|
.split("\n")
|
|
.filter(l => l.length > 0)
|
|
.map(l => l.trim().split("="))
|
|
.reduce((p, [key, value]) => ({...p, [key]: value}), {});
|
|
|
|
export default {
|
|
input: "src/main.ts",
|
|
output: {
|
|
sourcemap: true,
|
|
format: "iife",
|
|
name: "app",
|
|
file: "public/build/bundle.js"
|
|
},
|
|
plugins: [
|
|
svelte({
|
|
preprocess: sveltePreprocess(),
|
|
compilerOptions: {
|
|
// enable run-time checks when not in production
|
|
dev: !production
|
|
}
|
|
}),
|
|
// we"ll extract any component CSS out into
|
|
// a separate file - better for performance
|
|
css({ output: "bundle.css" }),
|
|
|
|
// 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,
|
|
preferBuiltins: false,
|
|
dedupe: ["svelte"],
|
|
}),
|
|
json(),
|
|
commonjs({
|
|
include: 'node_modules/**',
|
|
}),
|
|
typescript({
|
|
sourceMap: !production,
|
|
inlineSources: !production
|
|
}),
|
|
|
|
replace({
|
|
// 2 level deep object should be stringify
|
|
"process.env": JSON.stringify({
|
|
NODE_ENV: production ? "production" : "development",
|
|
...envVariables,
|
|
}),
|
|
}),
|
|
|
|
// Watch the `public` directory and refresh the
|
|
// browser on changes when not in production
|
|
!production && livereload("public"),
|
|
|
|
// Add dev server in development.
|
|
!production && dev({
|
|
dirs: ["public"],
|
|
spa: "public/index.html",
|
|
port: 5000,
|
|
proxy: {
|
|
"/api/*": "localhost:8000",
|
|
},
|
|
}),
|
|
|
|
// If we're building for production (npm run build
|
|
// instead of npm run dev), minify
|
|
production && terser({
|
|
output: { comments: false },
|
|
})
|
|
],
|
|
watch: {
|
|
clearScreen: false
|
|
},
|
|
onwarn: function(warning) {
|
|
// Skip certain warnings
|
|
if ( warning.code === "THIS_IS_UNDEFINED" ) { return; }
|
|
|
|
// console.warn everything else
|
|
console.warn( warning.message );
|
|
}
|
|
};
|