rollup expriment
parent
c80342417c
commit
14d00a0b97
File diff suppressed because it is too large
Load Diff
19
package.json
19
package.json
|
@ -12,7 +12,8 @@
|
|||
"server": "nodemon -w packages/server/dist --exec silverbullet",
|
||||
"test": "jest packages/*/{dist,build}/test",
|
||||
"clean-build": "npm run clean && npm run build && npm i && npm run build-plugs",
|
||||
"publish-all": "npm publish --access public --ws"
|
||||
"publish-all": "npm publish --access public --ws",
|
||||
"ru": "rollup -c rollup.config.ts"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@parcel/core": "2.5.0",
|
||||
|
@ -22,14 +23,26 @@
|
|||
"@parcel/transformer-sass": "2.5.0",
|
||||
"@parcel/transformer-webmanifest": "2.5.0",
|
||||
"@parcel/validator-typescript": "2.5.0",
|
||||
"@rollup/plugin-node-resolve": "^14.1.0",
|
||||
"@rollup/plugin-replace": "^4.0.0",
|
||||
"@rollup/plugin-typescript": "^8.5.0",
|
||||
"nodemon": "^2.0.19",
|
||||
"parcel": "2.5.0",
|
||||
"prettier": "^2.7.1",
|
||||
"process": "^0.11.10",
|
||||
"ts-node": "^10.9.1",
|
||||
"rollup": "^2.79.0",
|
||||
"rollup-plugin-scss": "^3.0.0",
|
||||
"rollup-plugin-sourcemaps": "^0.6.3",
|
||||
"rollup-plugin-string": "^3.0.0",
|
||||
"rollup-plugin-terser": "^7.0.2",
|
||||
"rollup-plugin-web-worker-loader": "^1.6.1",
|
||||
"typescript": "^4.8.3"
|
||||
},
|
||||
"workspaces": [
|
||||
"packages/*"
|
||||
]
|
||||
],
|
||||
"dependencies": {
|
||||
"@rollup/plugin-commonjs": "^22.0.2",
|
||||
"@rollup/plugin-json": "^4.1.0"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,10 +28,16 @@ class WebWorkerWrapper implements WorkerLike {
|
|||
}
|
||||
}
|
||||
|
||||
// @ts-ignore
|
||||
import SandboxWorker from "web-worker:./sandbox_worker";
|
||||
|
||||
export function createSandbox(plug: Plug<any>) {
|
||||
// ParcelJS will build this file into a worker.
|
||||
let worker = new Worker(new URL("sandbox_worker.ts", import.meta.url), {
|
||||
type: "module",
|
||||
});
|
||||
// let worker = new Worker(new URL("sandbox_worker.ts", import.meta.url), {
|
||||
// type: "module",
|
||||
// });
|
||||
|
||||
let worker = new SandboxWorker();
|
||||
|
||||
return new Sandbox(plug, new WebWorkerWrapper(worker));
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@ const pagesPath = args._[0] as string;
|
|||
const port = args.port;
|
||||
|
||||
const webappDistDir = realpathSync(
|
||||
`${nodeModulesDir}/node_modules/@silverbulletmd/web/dist`
|
||||
`${nodeModulesDir}/node_modules/@silverbulletmd/web/rdist`
|
||||
);
|
||||
// console.log("Webapp dist dir", webappDistDir);
|
||||
const plugDistDir = realpathSync(
|
||||
|
|
|
@ -3,10 +3,11 @@ import { parseYamlSettings, safeRun } from "@silverbulletmd/common/util";
|
|||
import { Space } from "@silverbulletmd/common/spaces/space";
|
||||
import { HttpSpacePrimitives } from "@silverbulletmd/common/spaces/http_space_primitives";
|
||||
|
||||
import "./styles/main.scss";
|
||||
|
||||
safeRun(async () => {
|
||||
let password: string | undefined =
|
||||
localStorage.getItem("password") || undefined;
|
||||
|
||||
let httpPrimitives = new HttpSpacePrimitives("", password);
|
||||
let settingsPageText = "";
|
||||
while (true) {
|
||||
|
@ -45,7 +46,6 @@ safeRun(async () => {
|
|||
window.editor = editor;
|
||||
});
|
||||
|
||||
// if (!isDesktop) {
|
||||
if (localStorage.getItem("disable_sw") !== "true") {
|
||||
if (navigator.serviceWorker) {
|
||||
navigator.serviceWorker
|
||||
|
@ -61,5 +61,3 @@ if (localStorage.getItem("disable_sw") !== "true") {
|
|||
);
|
||||
}
|
||||
}
|
||||
|
||||
// }
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { useEffect, useRef } from "react";
|
||||
// @ts-ignore
|
||||
import iframeHtml from "bundle-text:./panel.html";
|
||||
import iframeHtml from "./panel.html";
|
||||
import { Editor } from "../editor";
|
||||
|
||||
export function Panel({
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width" />
|
||||
<base href="/" />
|
||||
|
||||
<title>Silver Bullet</title>
|
||||
<style>
|
||||
html,
|
||||
body {
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
overflow: hidden;
|
||||
}
|
||||
</style>
|
||||
<script>
|
||||
document.documentElement.dataset.theme = localStorage.theme ?? "light";
|
||||
</script>
|
||||
<link rel="stylesheet" href="/bundle.css" />
|
||||
<script src="/bundle.js" defer=""></script>
|
||||
<link rel="manifest" href="/manifest.webmanifest" />
|
||||
<link rel="icon" type="image/x-icon" href="/favicon.0455ef5b.gif" />
|
||||
</head>
|
||||
<body>
|
||||
<div id="sb-root"></div>
|
||||
</body>
|
||||
</html>
|
|
@ -4,28 +4,28 @@
|
|||
|
||||
@font-face {
|
||||
font-family: "iA-Mono";
|
||||
src: url("../fonts/iAWriterMonoS-Regular.woff2");
|
||||
src: url("iAWriterMonoS-Regular.woff2");
|
||||
font-weight: normal;
|
||||
font-style: normal;
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: "iA-Mono";
|
||||
src: url("../fonts/iAWriterMonoS-Bold.woff2");
|
||||
src: url("iAWriterMonoS-Bold.woff2");
|
||||
font-weight: bold;
|
||||
font-style: normal;
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: "iA-Mono";
|
||||
src: url("../fonts/iAWriterMonoS-Italic.woff2");
|
||||
src: url("iAWriterMonoS-Italic.woff2");
|
||||
font-weight: normal;
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: "iA-Mono";
|
||||
src: url("../fonts/iAWriterMonoS-BoldItalic.woff2");
|
||||
src: url("iAWriterMonoS-BoldItalic.woff2");
|
||||
font-weight: bold;
|
||||
font-style: italic;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,50 @@
|
|||
import { nodeResolve } from "@rollup/plugin-node-resolve";
|
||||
import typescript from "@rollup/plugin-typescript";
|
||||
import json from "@rollup/plugin-json";
|
||||
import commonjs from "@rollup/plugin-commonjs";
|
||||
import { string } from "rollup-plugin-string";
|
||||
import replace from "@rollup/plugin-replace";
|
||||
import webWorkerLoader from "rollup-plugin-web-worker-loader";
|
||||
import scss from "rollup-plugin-scss";
|
||||
import { defineConfig } from "rollup";
|
||||
import { terser } from "rollup-plugin-terser";
|
||||
|
||||
export default defineConfig({
|
||||
input: {
|
||||
web: "packages/web/boot.ts",
|
||||
},
|
||||
|
||||
output: [
|
||||
{
|
||||
dir: ".",
|
||||
entryFileNames: "packages/[name]/rdist/bundle.js",
|
||||
format: "umd",
|
||||
sourcemap: true,
|
||||
},
|
||||
{
|
||||
dir: ".",
|
||||
entryFileNames: "packages/[name]/rdist/bundle.min.js",
|
||||
format: "umd",
|
||||
plugins: [terser()],
|
||||
},
|
||||
],
|
||||
|
||||
treeshake: "recommended",
|
||||
plugins: [
|
||||
typescript(),
|
||||
nodeResolve(),
|
||||
json(),
|
||||
commonjs(),
|
||||
string({
|
||||
include: "**/*.html",
|
||||
}),
|
||||
replace({
|
||||
"process.env.NODE_ENV": JSON.stringify("production"),
|
||||
preventAssignment: true,
|
||||
}),
|
||||
webWorkerLoader({}),
|
||||
scss({
|
||||
output: "packages/web/rdist/bundle.css",
|
||||
}),
|
||||
],
|
||||
});
|
Loading…
Reference in New Issue