cal.pub0.org/packages/embeds/embed-core/vite.config.js

40 lines
1.0 KiB
JavaScript
Raw Normal View History

2022-03-31 08:45:47 +00:00
require("dotenv").config({ path: "../../../.env" });
process.env.NEXT_PUBLIC_VERCEL_URL = process.env.VERCEL_URL;
2022-03-31 08:45:47 +00:00
const path = require("path");
const { defineConfig } = require("vite");
module.exports = defineConfig((configEnv) => {
const config = {
envPrefix: "NEXT_PUBLIC_",
base: "/embed/",
build: {
minify: "terser",
terserOptions: {
format: {
comments: false,
},
},
rollupOptions: {
input: {
preview: path.resolve(__dirname, "preview.html"),
embed: path.resolve(__dirname, "src/embed.ts"),
},
output: {
entryFileNames: "[name].js",
//FIXME: Can't specify UMD as import because preview is an app which doesn't support `format` and this setting apply to both input
//format: "umd",
dir: "../../../apps/web/public/embed",
},
},
},
};
if (configEnv.mode === "development") {
config.build.watch = {
include: ["src/**"],
};
}
return config;
2022-03-31 08:45:47 +00:00
});