resolve issue with missing vite-plugin-node-polyfills
add LibreJS licenses to all demo JS split browser build from node build add copyright info to license files update to use yarn v4.13.0 update to v0.9.2
This commit is contained in:
24
build.js
24
build.js
@@ -8,10 +8,11 @@ import {
|
||||
rm,
|
||||
writeFile,
|
||||
} from "node:fs/promises";
|
||||
import { dirname, join, resolve } from "node:path";
|
||||
import { dirname, resolve } from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
import { defineConfig, build as viteBuild } from "vite";
|
||||
import noBundlePlugin from "vite-plugin-no-bundle";
|
||||
import { nodePolyfills } from "vite-plugin-node-polyfills";
|
||||
|
||||
const __dirname = dirname(fileURLToPath(import.meta.url));
|
||||
|
||||
@@ -21,27 +22,25 @@ const browserOutPath = `${outputPathPrefix}-browser`;
|
||||
const browserOutDir = resolve(__dirname, browserOutPath);
|
||||
const demoOutDir = resolve(__dirname, `${outputPathPrefix}-demo`);
|
||||
|
||||
const entry = "src/index.ts";
|
||||
|
||||
const globalConfig = {
|
||||
libraryName: "twtxt-lib",
|
||||
basePath: resolve(__dirname),
|
||||
outDir: resolve(__dirname, outputPathPrefix),
|
||||
builds: [
|
||||
{
|
||||
entry,
|
||||
entry: "src/browser.ts",
|
||||
outDir: browserOutDir,
|
||||
outfile: "twtxt-lib.js",
|
||||
target: "browser",
|
||||
},
|
||||
{
|
||||
entry,
|
||||
entry: "src/browser.ts",
|
||||
outDir: browserOutDir,
|
||||
outfile: "twtxt-lib.min.js",
|
||||
target: "browser",
|
||||
},
|
||||
{
|
||||
entry,
|
||||
entry: "src/index.ts",
|
||||
outDir: resolve(__dirname, `${outputPathPrefix}-node`),
|
||||
target: "node",
|
||||
},
|
||||
@@ -84,7 +83,18 @@ const buildWithVite = async (config) => {
|
||||
const plugins = [
|
||||
dts({ exclude: ["./vitest.setup.ts", "**/__tests__/*.*"] }),
|
||||
];
|
||||
if (config.target !== "browser") plugins.push(noBundlePlugin());
|
||||
if (config.target !== "browser") {
|
||||
plugins.push([
|
||||
noBundlePlugin(),
|
||||
nodePolyfills({
|
||||
include: ["buffer"],
|
||||
|
||||
globals: {
|
||||
Buffer: true,
|
||||
},
|
||||
}),
|
||||
]);
|
||||
}
|
||||
|
||||
await viteBuild(
|
||||
defineConfig({
|
||||
|
||||
Reference in New Issue
Block a user