summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authormia <74628488+squili@users.noreply.github.com>2023-12-07 16:34:37 -0800
committermia <74628488+squili@users.noreply.github.com>2023-12-07 16:34:37 -0800
commit40a9263083ca7d11096ec4851ea61e97c7da79ae (patch)
treeae9cc8bb2c9594cbc90dbd1667aefc369eec9c58 /scripts
parentupd: add icons to radio buttons for note design and corner radius (diff)
downloadsharkey-40a9263083ca7d11096ec4851ea61e97c7da79ae.tar.gz
sharkey-40a9263083ca7d11096ec4851ea61e97c7da79ae.tar.bz2
sharkey-40a9263083ca7d11096ec4851ea61e97c7da79ae.zip
switch to more optimized containerfile
Diffstat (limited to 'scripts')
-rw-r--r--scripts/trim-deps.mjs35
1 files changed, 35 insertions, 0 deletions
diff --git a/scripts/trim-deps.mjs b/scripts/trim-deps.mjs
new file mode 100644
index 0000000000..2983f28cb4
--- /dev/null
+++ b/scripts/trim-deps.mjs
@@ -0,0 +1,35 @@
+// trims dependencies for production
+// only run after a full build
+
+import fs from 'node:fs'
+
+const checks = ['dependencies', 'optionalDependencies', 'devDependencies']
+
+function removeDeps(path, patterns) {
+ let pkg = JSON.parse(fs.readFileSync(path));
+ for (const pattern of patterns) {
+ if (typeof pattern === 'string') {
+ for (const check of checks) {
+ if (pkg[check] !== undefined && pkg[check][pattern] !== undefined) {
+ delete pkg[check][pattern];
+ }
+ }
+ } else if (pattern instanceof RegExp) {
+ for (const check of checks) {
+ if (pkg[check] !== undefined) {
+ for (const dep of Object.keys(pkg[check])) {
+ if (pattern.exec(dep) !== null) {
+ delete pkg[check][dep];
+ }
+ }
+ }
+ }
+ }
+ }
+ fs.writeFileSync(path, JSON.stringify(pkg, undefined, 2));
+}
+
+removeDeps('package.json', ['execa', 'cssnano', 'postcss', 'terser', 'typescript'])
+removeDeps('packages/backend/package.json', ['bufferutil', 'utf-8-validate', /^@swc\//, 'typescript'])
+removeDeps('packages/megalodon/package.json', [/^@types\//, 'typescript'])
+removeDeps('packages/misskey-js/package.json', [/^@swc\//, 'typescript'])