consolidate build scripts, reorganize source into src/ directory, fix favicon injection
This commit is contained in:
parent
2add5238b8
commit
0747a4540d
56 changed files with 46 additions and 45 deletions
|
|
@ -6,10 +6,8 @@ WORKDIR /build
|
||||||
COPY package.json package-lock.json ./
|
COPY package.json package-lock.json ./
|
||||||
RUN npm ci --ignore-scripts
|
RUN npm ci --ignore-scripts
|
||||||
|
|
||||||
COPY build.js build-ui.js ./
|
COPY build.js ./
|
||||||
COPY shims/ ./shims/
|
COPY src/ ./src/
|
||||||
COPY services/ ./services/
|
|
||||||
COPY ui/ ./ui/
|
|
||||||
|
|
||||||
RUN npm run build
|
RUN npm run build
|
||||||
|
|
||||||
|
|
|
||||||
17
build-ui.js
17
build-ui.js
|
|
@ -1,17 +0,0 @@
|
||||||
const esbuild = require("esbuild");
|
|
||||||
const sveltePlugin = require("esbuild-svelte");
|
|
||||||
const path = require("path");
|
|
||||||
|
|
||||||
esbuild.build({
|
|
||||||
entryPoints: [path.join(__dirname, "ui", "index.js")],
|
|
||||||
bundle: true,
|
|
||||||
outfile: path.join(__dirname, "dist", "ignis-ui.js"),
|
|
||||||
format: "iife",
|
|
||||||
globalName: "IgnisUI",
|
|
||||||
platform: "browser",
|
|
||||||
target: ["chrome90"],
|
|
||||||
mainFields: ["svelte", "browser", "module", "main"],
|
|
||||||
conditions: ["svelte", "browser"],
|
|
||||||
plugins: [sveltePlugin({ compilerOptions: { css: "injected" } })],
|
|
||||||
logLevel: "info",
|
|
||||||
}).catch(() => process.exit(1));
|
|
||||||
39
build.js
39
build.js
|
|
@ -1,15 +1,34 @@
|
||||||
const esbuild = require('esbuild');
|
const esbuild = require("esbuild");
|
||||||
const path = require('path');
|
const sveltePlugin = require("esbuild-svelte");
|
||||||
|
const path = require("path");
|
||||||
|
|
||||||
|
Promise.all([
|
||||||
|
// Build shim-loader.js
|
||||||
esbuild.build({
|
esbuild.build({
|
||||||
entryPoints: [path.join(__dirname, 'shims', 'loader.js')],
|
entryPoints: [path.join(__dirname, "src", "shims", "loader.js")],
|
||||||
bundle: true,
|
bundle: true,
|
||||||
outfile: path.join(__dirname, 'dist', 'shim-loader.js'),
|
outfile: path.join(__dirname, "dist", "shim-loader.js"),
|
||||||
format: 'iife',
|
format: "iife",
|
||||||
platform: 'browser',
|
platform: "browser",
|
||||||
target: ['chrome90'],
|
target: ["chrome90"],
|
||||||
alias: {
|
alias: {
|
||||||
'path': 'path-browserify',
|
path: "path-browserify",
|
||||||
},
|
},
|
||||||
logLevel: 'info',
|
logLevel: "info",
|
||||||
}).catch(() => process.exit(1));
|
}),
|
||||||
|
|
||||||
|
// Build ignis-ui.js
|
||||||
|
esbuild.build({
|
||||||
|
entryPoints: [path.join(__dirname, "src", "ui", "index.js")],
|
||||||
|
bundle: true,
|
||||||
|
outfile: path.join(__dirname, "dist", "ignis-ui.js"),
|
||||||
|
format: "iife",
|
||||||
|
globalName: "IgnisUI",
|
||||||
|
platform: "browser",
|
||||||
|
target: ["chrome90"],
|
||||||
|
mainFields: ["svelte", "browser", "module", "main"],
|
||||||
|
conditions: ["svelte", "browser"],
|
||||||
|
plugins: [sveltePlugin({ compilerOptions: { css: "injected" } })],
|
||||||
|
logLevel: "info",
|
||||||
|
}),
|
||||||
|
]).catch(() => process.exit(1));
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,10 @@
|
||||||
{
|
{
|
||||||
"name": "ignis",
|
"name": "ignis",
|
||||||
"version": "0.1.0",
|
"version": "0.4.0",
|
||||||
"private": true,
|
"private": true,
|
||||||
"description": "An Electron shim and server bridge for running Obsidian in a browser.",
|
"description": "An Electron shim and server bridge for running Obsidian in a browser.",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build:ui": "node build-ui.js",
|
"build": "node build.js",
|
||||||
"build:shims": "node build.js",
|
|
||||||
"build": "npm run build:ui && npm run build:shims",
|
|
||||||
"dev:server": "node server/index.js",
|
"dev:server": "node server/index.js",
|
||||||
"dev": "npm run build && npm run dev:server"
|
"dev": "npm run build && npm run dev:server"
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -37,15 +37,18 @@ function patchHtml(filePath) {
|
||||||
"\n",
|
"\n",
|
||||||
);
|
);
|
||||||
|
|
||||||
// Inject ignis assets before the first <script> tag
|
// Inject favicon into <head>
|
||||||
const ignisBlock =
|
html = html.replace(
|
||||||
' <link rel="icon" type="image/png" href="favicon.png">\n' +
|
"</head>",
|
||||||
' <script type="text/javascript" src="ignis-ui.js"></script>\n' +
|
' <link rel="icon" type="image/png" href="favicon.png">\n</head>',
|
||||||
' <script type="text/javascript" src="shim-loader.js"></script>\n';
|
);
|
||||||
|
|
||||||
|
// Inject ignis scripts before the first <script> tag
|
||||||
html = html.replace(
|
html = html.replace(
|
||||||
'<script type="text/javascript"',
|
'<script type="text/javascript"',
|
||||||
ignisBlock + '<script type="text/javascript"',
|
'<script type="text/javascript" src="ignis-ui.js"></script>\n' +
|
||||||
|
'<script type="text/javascript" src="shim-loader.js"></script>\n' +
|
||||||
|
'<script type="text/javascript"',
|
||||||
);
|
);
|
||||||
|
|
||||||
fs.writeFileSync(filePath, html);
|
fs.writeFileSync(filePath, html);
|
||||||
|
|
|
||||||
0
ui/bootstrap.js → src/ui/bootstrap.js
vendored
0
ui/bootstrap.js → src/ui/bootstrap.js
vendored
Loading…
Add table
Reference in a new issue