mirror of
				https://github.com/TriliumNext/Notes.git
				synced 2025-11-04 15:11:31 +08:00 
			
		
		
		
	chore(edit-docs): switch to esbuild
This commit is contained in:
		
							parent
							
								
									d70140c180
								
							
						
					
					
						commit
						be8749d84e
					
				@ -17,6 +17,51 @@
 | 
				
			|||||||
      "server"
 | 
					      "server"
 | 
				
			||||||
    ],
 | 
					    ],
 | 
				
			||||||
    "targets": {
 | 
					    "targets": {
 | 
				
			||||||
 | 
					      "build": {
 | 
				
			||||||
 | 
					        "executor": "@nx/esbuild:esbuild",
 | 
				
			||||||
 | 
					        "outputs": [
 | 
				
			||||||
 | 
					          "{options.outputPath}"
 | 
				
			||||||
 | 
					        ],
 | 
				
			||||||
 | 
					        "options": {
 | 
				
			||||||
 | 
					          "main": "apps/edit-docs/src/electron-edit-demo.ts",
 | 
				
			||||||
 | 
					          "outputPath": "apps/edit-docs/dist",
 | 
				
			||||||
 | 
					          "outputFileName": "main.js",
 | 
				
			||||||
 | 
					          "tsConfig": "apps/edit-docs/tsconfig.app.json",
 | 
				
			||||||
 | 
					          "platform": "node",
 | 
				
			||||||
 | 
					          "external": [
 | 
				
			||||||
 | 
					            "electron",
 | 
				
			||||||
 | 
					            "@electron/remote",
 | 
				
			||||||
 | 
					            "better-sqlite3",
 | 
				
			||||||
 | 
					            "./xhr-sync-worker.js"
 | 
				
			||||||
 | 
					          ],
 | 
				
			||||||
 | 
					          "format": [
 | 
				
			||||||
 | 
					            "cjs"
 | 
				
			||||||
 | 
					          ],
 | 
				
			||||||
 | 
					          "assets": [
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					              "glob": "**/*",
 | 
				
			||||||
 | 
					              "input": "apps/server/dist/node_modules",
 | 
				
			||||||
 | 
					              "output": "node_modules"
 | 
				
			||||||
 | 
					            },
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					              "glob": "**/*",
 | 
				
			||||||
 | 
					              "input": "apps/server/dist/assets",
 | 
				
			||||||
 | 
					              "output": "assets"
 | 
				
			||||||
 | 
					            },
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					              "glob": "**/*",
 | 
				
			||||||
 | 
					              "input": "apps/server/dist/public",
 | 
				
			||||||
 | 
					              "output": "public"
 | 
				
			||||||
 | 
					            },
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					              "glob": "xhr-sync-worker.js",
 | 
				
			||||||
 | 
					              "input": "apps/server/node_modules/jsdom/lib/jsdom/living/xhr",
 | 
				
			||||||
 | 
					              "output": ""
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					          ],
 | 
				
			||||||
 | 
					          "declarationRootDir": "apps/edit-docs/src"
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					      },
 | 
				
			||||||
      "rebuild-deps": {
 | 
					      "rebuild-deps": {
 | 
				
			||||||
        "executor": "nx:run-commands",
 | 
					        "executor": "nx:run-commands",
 | 
				
			||||||
        "dependsOn": [
 | 
					        "dependsOn": [
 | 
				
			||||||
@ -41,13 +86,31 @@
 | 
				
			|||||||
        "defaultConfiguration": "default",
 | 
					        "defaultConfiguration": "default",
 | 
				
			||||||
        "configurations": {
 | 
					        "configurations": {
 | 
				
			||||||
          "default": {
 | 
					          "default": {
 | 
				
			||||||
            "command": "electron .",
 | 
					            "command": "electron main.cjs",
 | 
				
			||||||
            "cwd": "./apps/edit-docs/dist"
 | 
					            "cwd": "{projectRoot}/dist"
 | 
				
			||||||
          },
 | 
					          },
 | 
				
			||||||
          "nixos": {
 | 
					          "nixos": {
 | 
				
			||||||
            "command": "nix-shell -p electron_35 --run \"electron .\"",
 | 
					            "command": "nix-shell -p electron_35 --run \"electron {projectRoot}/dist/main.cjs\"",
 | 
				
			||||||
            "forwardAllArgs": false,
 | 
					            "cwd": ".",
 | 
				
			||||||
            "cwd": "./apps/edit-docs/dist"
 | 
					            "forwardAllArgs": false
 | 
				
			||||||
 | 
					          }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					      },
 | 
				
			||||||
 | 
					      "serve-nodir": {
 | 
				
			||||||
 | 
					        "executor": "nx:run-commands",
 | 
				
			||||||
 | 
					        "dependsOn": [
 | 
				
			||||||
 | 
					          "rebuild-deps"
 | 
				
			||||||
 | 
					        ],
 | 
				
			||||||
 | 
					        "defaultConfiguration": "default",
 | 
				
			||||||
 | 
					        "configurations": {
 | 
				
			||||||
 | 
					          "default": {
 | 
				
			||||||
 | 
					            "command": "electron main.cjs",
 | 
				
			||||||
 | 
					            "cwd": "{projectRoot}/dist"
 | 
				
			||||||
 | 
					          },
 | 
				
			||||||
 | 
					          "nixos": {
 | 
				
			||||||
 | 
					            "command": "nix-shell -p electron_35 --run \"electron {projectRoot}/dist/main.cjs\"",
 | 
				
			||||||
 | 
					            "cwd": ".",
 | 
				
			||||||
 | 
					            "forwardAllArgs": false
 | 
				
			||||||
          }
 | 
					          }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
 | 
				
			|||||||
@ -15,6 +15,7 @@ import { parseNoteMetaFile } from "@triliumnext/server/src/services/in_app_help.
 | 
				
			|||||||
import { resolve } from "path";
 | 
					import { resolve } from "path";
 | 
				
			||||||
import electron from "electron";
 | 
					import electron from "electron";
 | 
				
			||||||
import { onReady } from "@triliumnext/desktop/src/electron-main.js";
 | 
					import { onReady } from "@triliumnext/desktop/src/electron-main.js";
 | 
				
			||||||
 | 
					import type NoteMeta from "@triliumnext/server/src/services/meta/note_meta.js";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
interface NoteMapping {
 | 
					interface NoteMapping {
 | 
				
			||||||
    rootNoteId: string;
 | 
					    rootNoteId: string;
 | 
				
			||||||
 | 
				
			|||||||
@ -40,4 +40,4 @@ async function exportData() {
 | 
				
			|||||||
    await exportToZipFile("root", "html", DEMO_ZIP_PATH);
 | 
					    await exportToZipFile("root", "html", DEMO_ZIP_PATH);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
await main();
 | 
					main();
 | 
				
			||||||
 | 
				
			|||||||
@ -1,16 +1,21 @@
 | 
				
			|||||||
{
 | 
					{
 | 
				
			||||||
  "extends": "../../tsconfig.base.json",
 | 
					  "extends": "../../tsconfig.base.json",
 | 
				
			||||||
  "compilerOptions": {
 | 
					  "compilerOptions": {
 | 
				
			||||||
 | 
					    "module": "ESNext",
 | 
				
			||||||
 | 
					    "moduleResolution": "bundler",
 | 
				
			||||||
 | 
					    "target": "ES2020",
 | 
				
			||||||
    "outDir": "dist",
 | 
					    "outDir": "dist",
 | 
				
			||||||
 | 
					    "strict": false,
 | 
				
			||||||
    "types": [
 | 
					    "types": [
 | 
				
			||||||
      "node"
 | 
					      "node",
 | 
				
			||||||
 | 
					      "express"
 | 
				
			||||||
    ],
 | 
					    ],
 | 
				
			||||||
    "rootDir": "src",
 | 
					    "rootDir": "src",
 | 
				
			||||||
    "tsBuildInfoFile": "dist/tsconfig.app.tsbuildinfo",
 | 
					    "tsBuildInfoFile": "dist/tsconfig.app.tsbuildinfo"
 | 
				
			||||||
    "verbatimModuleSyntax": false
 | 
					 | 
				
			||||||
  },
 | 
					  },
 | 
				
			||||||
  "include": [
 | 
					  "include": [
 | 
				
			||||||
    "src/**/*.ts"
 | 
					    "src/**/*.ts",
 | 
				
			||||||
 | 
					    "../server/src/*.d.ts"
 | 
				
			||||||
  ],
 | 
					  ],
 | 
				
			||||||
  "exclude": [
 | 
					  "exclude": [
 | 
				
			||||||
    "eslint.config.js",
 | 
					    "eslint.config.js",
 | 
				
			||||||
 | 
				
			|||||||
@ -1,53 +0,0 @@
 | 
				
			|||||||
const { NxAppWebpackPlugin } = require('@nx/webpack/app-plugin');
 | 
					 | 
				
			||||||
const CopyPlugin = require('copy-webpack-plugin');
 | 
					 | 
				
			||||||
const { join } = require('path');
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
const outputDir = join(__dirname, 'dist');
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
module.exports = {
 | 
					 | 
				
			||||||
  output: {
 | 
					 | 
				
			||||||
    path: join(__dirname, 'dist'),
 | 
					 | 
				
			||||||
  },
 | 
					 | 
				
			||||||
  module: {
 | 
					 | 
				
			||||||
    rules: [
 | 
					 | 
				
			||||||
      {
 | 
					 | 
				
			||||||
        test: /\.css$/i,
 | 
					 | 
				
			||||||
        type: "asset/source"
 | 
					 | 
				
			||||||
      }
 | 
					 | 
				
			||||||
    ]
 | 
					 | 
				
			||||||
  },
 | 
					 | 
				
			||||||
  plugins: [
 | 
					 | 
				
			||||||
    new NxAppWebpackPlugin({
 | 
					 | 
				
			||||||
      target: 'node',
 | 
					 | 
				
			||||||
      compiler: 'tsc',
 | 
					 | 
				
			||||||
      main: './src/electron-docs-main.ts',
 | 
					 | 
				
			||||||
      tsConfig: './tsconfig.app.json',
 | 
					 | 
				
			||||||
      optimization: false,
 | 
					 | 
				
			||||||
      outputHashing: 'none',
 | 
					 | 
				
			||||||
      generatePackageJson: true,
 | 
					 | 
				
			||||||
      externalDependencies: [
 | 
					 | 
				
			||||||
        "electron/main",
 | 
					 | 
				
			||||||
        "@electron/remote/main",
 | 
					 | 
				
			||||||
        "electron",
 | 
					 | 
				
			||||||
        "@electron/remote",        
 | 
					 | 
				
			||||||
        "better-sqlite3"
 | 
					 | 
				
			||||||
      ]
 | 
					 | 
				
			||||||
    }),
 | 
					 | 
				
			||||||
    new CopyPlugin({
 | 
					 | 
				
			||||||
      patterns: [
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
          from: "../desktop/dist/node_modules",
 | 
					 | 
				
			||||||
          to: join(outputDir, "node_modules")
 | 
					 | 
				
			||||||
        },
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
          from: "../desktop/dist/assets",
 | 
					 | 
				
			||||||
          to: join(outputDir, "assets")
 | 
					 | 
				
			||||||
        },
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
          from: "../desktop/dist/public",
 | 
					 | 
				
			||||||
          to: join(outputDir, "public")
 | 
					 | 
				
			||||||
        },
 | 
					 | 
				
			||||||
      ]
 | 
					 | 
				
			||||||
    })
 | 
					 | 
				
			||||||
  ],
 | 
					 | 
				
			||||||
};
 | 
					 | 
				
			||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user