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 ./
|
||||
RUN npm ci --ignore-scripts
|
||||
|
||||
COPY build.js build-ui.js ./
|
||||
COPY shims/ ./shims/
|
||||
COPY services/ ./services/
|
||||
COPY ui/ ./ui/
|
||||
COPY build.js ./
|
||||
COPY src/ ./src/
|
||||
|
||||
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));
|
||||
41
build.js
41
build.js
|
|
@ -1,15 +1,34 @@
|
|||
const esbuild = require('esbuild');
|
||||
const path = require('path');
|
||||
const esbuild = require("esbuild");
|
||||
const sveltePlugin = require("esbuild-svelte");
|
||||
const path = require("path");
|
||||
|
||||
esbuild.build({
|
||||
entryPoints: [path.join(__dirname, 'shims', 'loader.js')],
|
||||
Promise.all([
|
||||
// Build shim-loader.js
|
||||
esbuild.build({
|
||||
entryPoints: [path.join(__dirname, "src", "shims", "loader.js")],
|
||||
bundle: true,
|
||||
outfile: path.join(__dirname, 'dist', 'shim-loader.js'),
|
||||
format: 'iife',
|
||||
platform: 'browser',
|
||||
target: ['chrome90'],
|
||||
outfile: path.join(__dirname, "dist", "shim-loader.js"),
|
||||
format: "iife",
|
||||
platform: "browser",
|
||||
target: ["chrome90"],
|
||||
alias: {
|
||||
'path': 'path-browserify',
|
||||
path: "path-browserify",
|
||||
},
|
||||
logLevel: 'info',
|
||||
}).catch(() => process.exit(1));
|
||||
logLevel: "info",
|
||||
}),
|
||||
|
||||
// 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",
|
||||
"version": "0.1.0",
|
||||
"version": "0.4.0",
|
||||
"private": true,
|
||||
"description": "An Electron shim and server bridge for running Obsidian in a browser.",
|
||||
"scripts": {
|
||||
"build:ui": "node build-ui.js",
|
||||
"build:shims": "node build.js",
|
||||
"build": "npm run build:ui && npm run build:shims",
|
||||
"build": "node build.js",
|
||||
"dev:server": "node server/index.js",
|
||||
"dev": "npm run build && npm run dev:server"
|
||||
},
|
||||
|
|
|
|||
|
|
@ -37,15 +37,18 @@ function patchHtml(filePath) {
|
|||
"\n",
|
||||
);
|
||||
|
||||
// Inject ignis assets before the first <script> tag
|
||||
const ignisBlock =
|
||||
' <link rel="icon" type="image/png" href="favicon.png">\n' +
|
||||
' <script type="text/javascript" src="ignis-ui.js"></script>\n' +
|
||||
' <script type="text/javascript" src="shim-loader.js"></script>\n';
|
||||
// Inject favicon into <head>
|
||||
html = html.replace(
|
||||
"</head>",
|
||||
' <link rel="icon" type="image/png" href="favicon.png">\n</head>',
|
||||
);
|
||||
|
||||
// Inject ignis scripts before the first <script> tag
|
||||
html = html.replace(
|
||||
'<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);
|
||||
|
|
|
|||
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