-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
350 additions
and
711 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,26 @@ | ||
module.exports = { | ||
root: true, | ||
extends: ["./node_modules/@terwer/eslint-config-custom/index.cjs"], | ||
ignorePatterns: ["node_modules/"], | ||
} | ||
extends: [ | ||
"eslint:recommended", | ||
"plugin:@typescript-eslint/recommended", | ||
"turbo", | ||
"prettier", | ||
], | ||
|
||
parser: "@typescript-eslint/parser", | ||
|
||
plugins: ["@typescript-eslint", "prettier"], | ||
|
||
rules: { | ||
// Note: you must disable the base rule as it can report incorrect errors | ||
semi: "off", | ||
quotes: "off", | ||
"no-undef": "off", | ||
"@typescript-eslint/no-var-requires": "off", | ||
"@typescript-eslint/no-this-alias": "off", | ||
"@typescript-eslint/no-non-null-assertion": "off", | ||
"@typescript-eslint/no-unused-vars": "off", | ||
"@typescript-eslint/no-explicit-any": "off", | ||
"turbo/no-undeclared-env-vars": "off", | ||
"prettier/prettier": "error", | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
# publisher-main | ||
|
||
|
||
main module for publisher | ||
|
||
## Usage | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,7 @@ | ||
import { describe, expect, it } from "vitest" | ||
import init from "./index" | ||
import { describe, it } from "vitest" | ||
|
||
describe("publisher-main", () => { | ||
it("index", () => { | ||
expect(init()).toBe("ok") | ||
describe("index", () => { | ||
it("test index", () => { | ||
console.log("hello") | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
const init = () => { | ||
return "ok" | ||
} | ||
import { Plugin } from "siyuan" | ||
|
||
export default init | ||
export default class PluginSample extends Plugin { | ||
onload() { | ||
console.log("Publish Tool loaded2333") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,63 +1,106 @@ | ||
/// <reference types="vitest" /> | ||
|
||
import { resolve } from "path" | ||
import { defineConfig } from "vite" | ||
import { join } from "path" | ||
import { viteStaticCopy } from "vite-plugin-static-copy" | ||
// import viteTsConfigPaths from "vite-tsconfig-paths" | ||
import dts from "vite-plugin-dts" | ||
import minimist from "minimist" | ||
import livereload from "rollup-plugin-livereload" | ||
|
||
const args = minimist(process.argv.slice(2)) | ||
const isWatch = args.watch || args.w | ||
const devDistDir = "/Users/terwer/Documents/mydocs/SiYuanWorkspace/public/data/plugins/publish-tool" | ||
const distDir = isWatch ? devDistDir : "./dist" | ||
|
||
console.log("isWatch=>", isWatch) | ||
console.log("distDir=>", distDir) | ||
|
||
// https://vitejs.dev/config/ | ||
export default defineConfig({ | ||
plugins: [ | ||
dts({ | ||
entryRoot: "src", | ||
tsConfigFilePath: join(__dirname, "tsconfig.json"), | ||
skipDiagnostics: true, | ||
}), | ||
|
||
// viteTsConfigPaths({ | ||
// root: "../../", | ||
// }), | ||
|
||
viteStaticCopy({ | ||
targets: [ | ||
{ | ||
src: "README.md", | ||
dest: "./", | ||
}, | ||
], | ||
}), | ||
], | ||
|
||
// Uncomment this if you are using workers. | ||
// worker: { | ||
// plugins: [ | ||
// viteTsConfigPaths({ | ||
// root: '../../', | ||
// }), | ||
// ], | ||
// }, | ||
|
||
// Configuration for building your library. | ||
// See: https://vitejs.dev/guide/build.html#library-mode | ||
// 项目根目录 | ||
// root: "./", | ||
|
||
// 项目部署的基础路径 | ||
// base: "", | ||
|
||
// 静态资源服务文件夹 | ||
// publicDir: "public", | ||
|
||
build: { | ||
// 浏览器兼容性 ‘esnext’ | 'modules' | ||
// https://vitejs.dev/config/build-options.html#build-target | ||
// target: "modules", | ||
|
||
// 输出路径 | ||
outDir: distDir, | ||
|
||
// 生成静态资源的存放路径 | ||
// assetsDir: "./assets", | ||
// 小于此阈值的导入或引用资源将内联为 base64 编码, 以避免额外的http请求, 设置为 0, 可以完全禁用此项, | ||
assetsInlineLimit: 4096, | ||
// 启动 / 禁用 CSS 代码拆分 | ||
cssCodeSplit: true, | ||
// 构建后是否生成 source map 文件 | ||
sourcemap: false, | ||
|
||
// 设置为 false 可以禁用最小化混淆 | ||
// 或是用来指定是应用哪种混淆器 | ||
// boolean | 'terser' | 'esbuild' | ||
// 不压缩,用于调试 | ||
minify: isWatch ? false : "terser", | ||
terserOptions: { | ||
compress: { | ||
// 生产环境时移除console | ||
drop_console: true, | ||
drop_debugger: true, | ||
}, | ||
}, | ||
|
||
lib: { | ||
// Could also be a dictionary or array of multiple entry points. | ||
entry: "src/index.ts", | ||
// Could also be a dictionary or array of multiple entry points | ||
entry: resolve(__dirname, "src/index.ts"), | ||
// the proper extensions will be added | ||
fileName: "index", | ||
// Change this to the formats you want to support. | ||
// Don't forgot to update your package.json as well. | ||
formats: ["es"], | ||
formats: ["cjs"], | ||
}, | ||
|
||
rollupOptions: { | ||
// External packages that should not be bundled into your library. | ||
external: [], | ||
plugins: [...(isWatch ? [livereload(devDistDir)] : [])] as Plugin[], | ||
|
||
// make sure to externalize deps that shouldn't be bundled | ||
// into your library | ||
external: ["siyuan"], | ||
|
||
output: { | ||
chunkFileNames: "static/js/[name]-[hash].js", | ||
// entryFileNames: "static/js/[name]-[hash].js", | ||
entryFileNames: "[name].js", | ||
assetFileNames: "static/[ext]/[name]-[hash].[ext]", | ||
manualChunks(id) { | ||
if (id.includes("node_modules")) { | ||
let arr = id.toString().split("node_modules/")[1].split("/") | ||
// pnpm单独处理 | ||
if (id.includes(".pnpm")) { | ||
arr = id.toString().split(".pnpm/")[1].split("/") | ||
} | ||
const dep = arr[0].split("@")[0].replace(/\./g, "-") | ||
// console.log("id=>", id) | ||
// console.log("dep=>", dep) | ||
if (dep !== "") { | ||
return "vendor_" + dep | ||
} | ||
return "vendor" | ||
} | ||
}, | ||
}, | ||
}, | ||
}, | ||
|
||
test: { | ||
globals: true, | ||
// environment: "node", | ||
environment: "jsdom", | ||
// setupFiles: ["./setup.ts"], | ||
deps: { | ||
// inline: [], | ||
}, | ||
include: ["src/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}"], | ||
}, | ||
}) |
Oops, something went wrong.