-
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #87 from BobbyWibowo/pr-3.2.13
feat: 3.2.13 bug fixes + more hacks for vencord plugin edition
- Loading branch information
Showing
10 changed files
with
465 additions
and
78 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,6 +1,6 @@ | ||
{ | ||
"name": "magane", | ||
"version": "3.2.12", | ||
"version": "3.2.13", | ||
"description": "A lie about a lie... It turns inside-out on itself.", | ||
"author": "Pitu <[email protected]>", | ||
"license": "MIT", | ||
|
@@ -18,12 +18,14 @@ | |
"build": "rollup -c", | ||
"dev": "rollup -c -w", | ||
"build-bd": "rollup -c rollup-bd.config.js", | ||
"dev-bd": "rollup -c rollup-bd.config.js -w" | ||
"dev-bd": "rollup -c rollup-bd.config.js -w", | ||
"build-vc": "rollup -c rollup-vencord.config.js", | ||
"dev-vc": "rollup -c rollup-vencord.config.js -w" | ||
}, | ||
"devDependencies": { | ||
"@rollup/plugin-commonjs": "^11.1.0", | ||
"@rollup/plugin-node-resolve": "^11.2.1", | ||
"@rollup/plugin-replace": "^4.0.0", | ||
"@rollup/plugin-replace": "^5.0.2", | ||
"eslint": "^6.8.0", | ||
"eslint-config-aqua": "^7.2.0", | ||
"eslint-plugin-svelte3": "^2.7.3", | ||
|
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 |
---|---|---|
@@ -0,0 +1,112 @@ | ||
import svelte from 'rollup-plugin-svelte'; | ||
import resolve from '@rollup/plugin-node-resolve'; | ||
import commonjs from '@rollup/plugin-commonjs'; | ||
import command from 'rollup-plugin-command'; | ||
import { terser } from 'rollup-plugin-terser'; | ||
import replace from '@rollup/plugin-replace'; | ||
import postcss from 'rollup-plugin-postcss'; | ||
import postcssPresetEnv from 'postcss-preset-env'; | ||
import autoPreprocess from 'svelte-preprocess'; | ||
import path from 'path'; | ||
|
||
const production = !process.env.ROLLUP_WATCH; | ||
const file = path.resolve(__dirname, production ? 'dist' : 'dist-dev', 'magane.vencord.js'); | ||
|
||
export default { | ||
input: 'src/vencord-main.js', | ||
output: { | ||
file, | ||
format: 'cjs', | ||
name: 'app', | ||
// BetterDiscord won't make sourcemaps available to DevTools anyways, | ||
// and we are not minifying processed output to follow BetterDiscord guidelines, | ||
// so might as well not generate them altogether. | ||
sourcemap: false | ||
}, | ||
plugins: [ | ||
svelte({ | ||
dev: !production, | ||
emitCss: true, | ||
preprocess: autoPreprocess() | ||
}), | ||
postcss({ | ||
extensions: ['.css', '.scss'], | ||
plugins: [ | ||
postcssPresetEnv() | ||
], | ||
inject: (cssVariableName, fileId) => { | ||
// Extract packaga name if available | ||
const match = fileId.match(/[\/]node_modules[\/](.*?)[\/]/); | ||
let pkg = ''; | ||
if (match) pkg = `${match[1]}-`; | ||
// Normalize basename | ||
const id = pkg + path.basename(fileId).replace(/\./, '_'); | ||
// Arguably hacky.., but cleanest method that I could think of | ||
return 'if (typeof window.MAGANE_STYLES !== "object") window.MAGANE_STYLES = {};\n' + | ||
`window.MAGANE_STYLES["${id}"] = ${cssVariableName};`; | ||
} | ||
}), | ||
resolve({ | ||
browser: true | ||
}), | ||
commonjs(), | ||
production && terser({ | ||
ecma: 2017, | ||
compress: { | ||
keep_classnames: true, | ||
keep_fnames: true, | ||
passes: 1 | ||
}, | ||
mangle: false, | ||
output: { | ||
beautify: true, | ||
keep_numbers: true, | ||
indent_level: 4 | ||
} | ||
}), | ||
production && replace({ | ||
delimiters: ['', ''], | ||
preventAssignment: false, | ||
values: { | ||
' ': '\t' | ||
} | ||
}), | ||
production && replace({ | ||
delimiters: ['', ''], | ||
preventAssignment: false, | ||
values: { | ||
'"use strict";': '"use strict"\n__VencordImports__;' | ||
} | ||
}), | ||
!production && replace({ | ||
delimiters: ['', ''], | ||
preventAssignment: false, | ||
values: { | ||
'\'use strict\';': '\'use strict\';\n__VencordImports__;' | ||
} | ||
}), | ||
replace({ | ||
delimiters: ['', ''], | ||
preventAssignment: false, | ||
values: { | ||
'__VencordImports__;': 'import definePlugin from "@utils/types";\nimport { findByPropsLazy, findLazy } from "@webpack";\nimport { Alerts, Toasts } from "@webpack/common";', | ||
'VencordApi.': '', | ||
|
||
// Svelte syntax, lmao.. | ||
'$$invalidate(0, mountType)': '$$invalidate(0, mountType = MountType.VENCORD)', | ||
|
||
// This is so hacky, lmao | ||
'var vencordMain = definePlugin({': 'export default definePlugin({', | ||
'module.exports = vencordMain;': '' | ||
} | ||
}), | ||
Boolean(process.env.VENCORD_PLUGIN_PATH) && | ||
command(`cp --force "${file}" "${process.env.VENCORD_PLUGIN_PATH}"`, { | ||
once: false, | ||
wait: true | ||
}) | ||
], | ||
watch: { | ||
clearScreen: false | ||
} | ||
}; |
Oops, something went wrong.