Skip to content

Commit

Permalink
refactor with typescript and rollup
Browse files Browse the repository at this point in the history
  • Loading branch information
ourongxing committed Aug 22, 2021
1 parent 56fc965 commit 38699ae
Show file tree
Hide file tree
Showing 980 changed files with 157,768 additions and 948 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# npm
node_modules
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"typescript.tsdk": "node_modules/typescript/lib"
}
21 changes: 0 additions & 21 deletions LICENSE

This file was deleted.

5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
# ohmymn
Powerful Addon for Marginnote3
# OhMyMN

Maybe the most powerful add of Marginnote3
File renamed without changes
Binary file added dist/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions dist/main.js

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions dist/mnaddon.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"addonid": "marginnote.extension.ohmymn",
"author": "ourongxing",
"title": "OhMyMN",
"version": "0.9.0",
"marginnote_version_min": "3.7.10",
"cert_key": ""
}
Binary file added dist/ohmymn.mnaddon
Binary file not shown.
230 changes: 0 additions & 230 deletions main.js

This file was deleted.

4 changes: 2 additions & 2 deletions mnaddon.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"addonid": "marginnote.extension.onmymn",
"addonid": "marginnote.extension.ohmymn",
"author": "ourongxing",
"title": "OhMyMN",
"version": "0.1",
"version": "0.9.0",
"marginnote_version_min": "3.7.10",
"cert_key": ""
}
31 changes: 31 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"name": "ohmymn",
"author": "ourongxing",
"version": "0.9.0",
"license": "MIT",
"description": "Maybe the most powerful addon of Marginnote3",
"main": "",
"scripts": {
"build": "NODE_ENV=production rollup --config rollup.config.js",
"dev": "NODE_ENV=development rollup -w --config rollup.config.js"
},
"keywords": [
"marginote",
"addon",
"typescript"
],
"devDependencies": {
"@rollup/plugin-strip": "^2.1.0",
"@rollup/plugin-typescript": "^8.2.0",
"rollup": "^2.42.4",
"rollup-plugin-copy2": "^0.2.0",
"rollup-plugin-json": "^4.0.0",
"rollup-plugin-uglify": "^6.0.4",
"rollup-plugin-zip": "^1.0.1",
"rollup-watch": "^4.3.1",
"ts-jest": "^26.5.4",
"tslib": "^2.1.0",
"typescript": "^4.2.3"
},
"dependencies": {}
}
52 changes: 52 additions & 0 deletions rollup.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import typescript from "@rollup/plugin-typescript";
import copy from "rollup-plugin-copy2";
import json from "rollup-plugin-json";
import zip from 'rollup-plugin-zip';
import { uglify } from "rollup-plugin-uglify";
import strip from '@rollup/plugin-strip';

// 判断是否为开发环境
const isDev = () => process.env.NODE_ENV === 'development';

const banner = `/*
THIS IS A GENERATED/BUNDLED FILE BY ROLLUP
if you want to view the source visit the plugins github repository
https://github.com/ourongxing/ohmymn
*/
`;

// 把用户名换一下就行,亲测无法使用 ~
const dir = isDev() ? "/Users/ourongxing/Library/Containers/QReader.MarginStudyMac/Data/Library/MarginNote Extensions/marginnote.extension.ohmymn" : "./dist"
export default {
input: ["src/main.ts"],
output: {
dir: dir,
format: "iife",
exports: "none",
sourcemap: false,
banner,
},
watch: {
exclude: '../node_modules/**'
},
plugins: [
typescript(),
json({
compact: true,
}),
copy({
assets: [
"mnaddon.json",
["assets/logo.png", "logo.png"]
]
}),
!isDev() && strip({
include: ["**/*.ts",],
functions: ["log"]
}),
!isDev() && uglify(),
!isDev() && zip({
file: "ohmymn.mnaddon"
})
],
};
Loading

0 comments on commit 38699ae

Please sign in to comment.