Made webpack distribution have als little dependencies als possible
Closes #14
This commit is contained in:
parent
8e1cd73f39
commit
fbaedc7049
@ -45,6 +45,15 @@
|
|||||||
"thirty-two": "^1.0.2",
|
"thirty-two": "^1.0.2",
|
||||||
"typeorm": "^0.3.7"
|
"typeorm": "^0.3.7"
|
||||||
},
|
},
|
||||||
|
"runtimeDependencies": [
|
||||||
|
"@nestjs/common",
|
||||||
|
"@nestjs/core",
|
||||||
|
"@nestjs/platform-fastify",
|
||||||
|
"@nestjs/serve-static",
|
||||||
|
"argon2",
|
||||||
|
"sqlite3",
|
||||||
|
"typeorm"
|
||||||
|
],
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@nestjs/cli": "^9.0.0",
|
"@nestjs/cli": "^9.0.0",
|
||||||
"@nestjs/schematics": "^9.0.1",
|
"@nestjs/schematics": "^9.0.1",
|
||||||
|
@ -11,7 +11,8 @@
|
|||||||
"outDir": "./dist",
|
"outDir": "./dist",
|
||||||
"baseUrl": "./",
|
"baseUrl": "./",
|
||||||
"incremental": true,
|
"incremental": true,
|
||||||
"skipLibCheck": true
|
"skipLibCheck": true,
|
||||||
|
"resolveJsonModule": true
|
||||||
},
|
},
|
||||||
"exclude": ["node_modules", "dist", "test", "**/*spec.ts", "frontend"]
|
"exclude": ["node_modules", "dist", "test", "**/*spec.ts", "frontend"]
|
||||||
}
|
}
|
||||||
|
@ -2,14 +2,21 @@ import { DefinePlugin } from 'webpack';
|
|||||||
import * as nodeExternals from 'webpack-node-externals';
|
import * as nodeExternals from 'webpack-node-externals';
|
||||||
import * as copyPlugin from 'copy-webpack-plugin';
|
import * as copyPlugin from 'copy-webpack-plugin';
|
||||||
import { resolve } from 'path';
|
import { resolve } from 'path';
|
||||||
|
import * as pkg from './package.json';
|
||||||
|
|
||||||
function transform_package(input: Buffer): string {
|
function transform_package(input: Buffer): string {
|
||||||
const pkg = JSON.parse(input.toString());
|
const pkg = JSON.parse(input.toString());
|
||||||
delete pkg['devDependencies'];
|
|
||||||
delete pkg['jest'];
|
|
||||||
pkg['scripts'] = {
|
pkg['scripts'] = {
|
||||||
start: 'node server.js'
|
start: 'node server.js'
|
||||||
};
|
};
|
||||||
|
pkg['dependencies'] = Object.fromEntries(
|
||||||
|
Object.entries<string>(pkg['dependencies']).filter((dep) =>
|
||||||
|
pkg['runtimeDependencies'].includes(dep[0])
|
||||||
|
)
|
||||||
|
);
|
||||||
|
delete pkg['runtimeDependencies'];
|
||||||
|
delete pkg['devDependencies'];
|
||||||
|
delete pkg['jest'];
|
||||||
return JSON.stringify(pkg);
|
return JSON.stringify(pkg);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -25,10 +32,6 @@ export default {
|
|||||||
from: resolve(__dirname, 'package.json'),
|
from: resolve(__dirname, 'package.json'),
|
||||||
to: resolve(__dirname, 'dist', 'package.json'),
|
to: resolve(__dirname, 'dist', 'package.json'),
|
||||||
transform: transform_package
|
transform: transform_package
|
||||||
},
|
|
||||||
{
|
|
||||||
from: resolve(__dirname, 'yarn.lock'),
|
|
||||||
to: resolve(__dirname, 'dist', 'yarn.lock')
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
@ -51,5 +54,13 @@ export default {
|
|||||||
filename: 'server.js',
|
filename: 'server.js',
|
||||||
path: resolve(__dirname, 'dist')
|
path: resolve(__dirname, 'dist')
|
||||||
},
|
},
|
||||||
externals: [nodeExternals()]
|
externals: [
|
||||||
|
nodeExternals({
|
||||||
|
allowlist: (dep) => !pkg.runtimeDependencies.includes(dep)
|
||||||
|
})
|
||||||
|
],
|
||||||
|
performance: {
|
||||||
|
maxEntrypointSize: 512 * 1024 * 1024,
|
||||||
|
maxAssetSize: 512 * 1024 * 1024
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user