Я собираю с помощью rollup
в package.json в scripts добавляем
"build:server": "rollup --config server/rollup.config.js",
в package.json в dependencies добавляем
"rollup-plugin-json": "^4.0.0",
"rollup-plugin-terser": "^5.3.0",
"rollup-plugin-typescript2": "^0.26.0",
rollup.config.js
import typescript from 'rollup-plugin-typescript2';
import resolve from '@rollup/plugin-node-resolve';
import commonjs from '@rollup/plugin-commonjs';
import json from 'rollup-plugin-json';
import pkg from "../package.json";
import copy from 'rollup-plugin-copy';
export default [
{
input: 'server/server.ts',
plugins:[
typescript({
typescript: require('typescript'),
"declaration": false,
"module": "esnext",
"noImplicitAny": false,
"target": "es5",
"skipLibCheck": true,
"allowSyntheticDefaultImports": true,
"lib": ["dom", "es6"],
"typeRoots": ["node_modules/@types"]
}),
resolve({
browser: false,
main:true
}),
json(),
commonjs(),
],
external: [
...Object.keys(pkg.dependencies || {})
],
output: {
file: 'dist/server/server.js',
format: 'cjs'
}
},
]