添加打包启动
This commit is contained in:
parent
3c689c1cba
commit
b4cca6e345
19
pnpm-lock.yaml
generated
19
pnpm-lock.yaml
generated
@ -263,6 +263,9 @@ importers:
|
|||||||
'@rollup/plugin-node-resolve':
|
'@rollup/plugin-node-resolve':
|
||||||
specifier: ^15.3.0
|
specifier: ^15.3.0
|
||||||
version: 15.3.0(rollup@4.26.0)
|
version: 15.3.0(rollup@4.26.0)
|
||||||
|
'@rollup/plugin-replace':
|
||||||
|
specifier: ^6.0.1
|
||||||
|
version: 6.0.1(rollup@4.26.0)
|
||||||
'@rollup/plugin-typescript':
|
'@rollup/plugin-typescript':
|
||||||
specifier: ^12.1.1
|
specifier: ^12.1.1
|
||||||
version: 12.1.1(rollup@4.26.0)(tslib@2.8.1)(typescript@5.6.3)
|
version: 12.1.1(rollup@4.26.0)(tslib@2.8.1)(typescript@5.6.3)
|
||||||
@ -745,6 +748,15 @@ packages:
|
|||||||
rollup:
|
rollup:
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
|
'@rollup/plugin-replace@6.0.1':
|
||||||
|
resolution: {integrity: sha512-2sPh9b73dj5IxuMmDAsQWVFT7mR+yoHweBaXG2W/R8vQ+IWZlnaI7BR7J6EguVQUp1hd8Z7XuozpDjEKQAAC2Q==}
|
||||||
|
engines: {node: '>=14.0.0'}
|
||||||
|
peerDependencies:
|
||||||
|
rollup: ^1.20.0||^2.0.0||^3.0.0||^4.0.0
|
||||||
|
peerDependenciesMeta:
|
||||||
|
rollup:
|
||||||
|
optional: true
|
||||||
|
|
||||||
'@rollup/plugin-terser@0.4.4':
|
'@rollup/plugin-terser@0.4.4':
|
||||||
resolution: {integrity: sha512-XHeJC5Bgvs8LfukDwWZp7yeqin6ns8RTl2B9avbejt6tZqsqvVoWI7ZTQrcNsfKEDWBTnTxM8nMDkO2IFFbd0A==}
|
resolution: {integrity: sha512-XHeJC5Bgvs8LfukDwWZp7yeqin6ns8RTl2B9avbejt6tZqsqvVoWI7ZTQrcNsfKEDWBTnTxM8nMDkO2IFFbd0A==}
|
||||||
engines: {node: '>=14.0.0'}
|
engines: {node: '>=14.0.0'}
|
||||||
@ -4632,6 +4644,13 @@ snapshots:
|
|||||||
optionalDependencies:
|
optionalDependencies:
|
||||||
rollup: 4.26.0
|
rollup: 4.26.0
|
||||||
|
|
||||||
|
'@rollup/plugin-replace@6.0.1(rollup@4.26.0)':
|
||||||
|
dependencies:
|
||||||
|
'@rollup/pluginutils': 5.1.3(rollup@4.26.0)
|
||||||
|
magic-string: 0.30.12
|
||||||
|
optionalDependencies:
|
||||||
|
rollup: 4.26.0
|
||||||
|
|
||||||
'@rollup/plugin-terser@0.4.4(rollup@4.24.0)':
|
'@rollup/plugin-terser@0.4.4(rollup@4.24.0)':
|
||||||
dependencies:
|
dependencies:
|
||||||
serialize-javascript: 6.0.2
|
serialize-javascript: 6.0.2
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
"description": "pm2的服务",
|
"description": "pm2的服务",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"watch": "rollup -c rollup.config.mjs -w",
|
"watch": "cross-env NODE_ENV=development rollup -c rollup.config.mjs -w",
|
||||||
"dev": "cross-env NODE_ENV=development nodemon --delay 2.5 -e js,cjs,mjs --exec node dist/app.mjs",
|
"dev": "cross-env NODE_ENV=development nodemon --delay 2.5 -e js,cjs,mjs --exec node dist/app.mjs",
|
||||||
"test": "tsx test/**/*.ts",
|
"test": "tsx test/**/*.ts",
|
||||||
"dev:watch": "concurrently -n \"Watch,Dev\" -c \"green,blue\" \"npm run watch\" \"sleep 1 && npm run dev\" ",
|
"dev:watch": "concurrently -n \"Watch,Dev\" -c \"green,blue\" \"npm run watch\" \"sleep 1 && npm run dev\" ",
|
||||||
@ -17,7 +17,7 @@
|
|||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"app": {
|
"app": {
|
||||||
"type": "service"
|
"type": "inline"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@abearxiong/auth": "1.0.2",
|
"@abearxiong/auth": "1.0.2",
|
||||||
@ -25,14 +25,15 @@
|
|||||||
"@kevisual/router": "0.0.4-alpha-8",
|
"@kevisual/router": "0.0.4-alpha-8",
|
||||||
"nanoid": "^5.0.8",
|
"nanoid": "^5.0.8",
|
||||||
"pg": "^8.13.1",
|
"pg": "^8.13.1",
|
||||||
"sequelize": "^6.37.5",
|
"pm2": "^5.4.3",
|
||||||
"pm2": "^5.4.3"
|
"sequelize": "^6.37.5"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@rollup/plugin-alias": "^5.1.1",
|
"@rollup/plugin-alias": "^5.1.1",
|
||||||
"@rollup/plugin-commonjs": "^28.0.1",
|
"@rollup/plugin-commonjs": "^28.0.1",
|
||||||
"@rollup/plugin-json": "^6.1.0",
|
"@rollup/plugin-json": "^6.1.0",
|
||||||
"@rollup/plugin-node-resolve": "^15.3.0",
|
"@rollup/plugin-node-resolve": "^15.3.0",
|
||||||
|
"@rollup/plugin-replace": "^6.0.1",
|
||||||
"@rollup/plugin-typescript": "^12.1.1",
|
"@rollup/plugin-typescript": "^12.1.1",
|
||||||
"@types/node": "^22.9.0",
|
"@types/node": "^22.9.0",
|
||||||
"concurrently": "^9.1.0",
|
"concurrently": "^9.1.0",
|
||||||
|
@ -6,9 +6,13 @@ import commonjs from '@rollup/plugin-commonjs';
|
|||||||
import json from '@rollup/plugin-json';
|
import json from '@rollup/plugin-json';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import alias from '@rollup/plugin-alias';
|
import alias from '@rollup/plugin-alias';
|
||||||
import esbuild from 'rollup-plugin-esbuild'
|
import esbuild from 'rollup-plugin-esbuild';
|
||||||
// import replace from '@rollup/plugin-replace';
|
import replace from '@rollup/plugin-replace';
|
||||||
|
|
||||||
|
const isDev = process.env.NODE_ENV === 'development';
|
||||||
|
// 是否内联应用,内联应用不会启动服务,只会导出 App 实例,从package.json中获取
|
||||||
|
const exportApp = true;
|
||||||
|
console.log('isDev================:', isDev);
|
||||||
/**
|
/**
|
||||||
* @type {import('rollup').RollupOptions}
|
* @type {import('rollup').RollupOptions}
|
||||||
*/
|
*/
|
||||||
@ -21,6 +25,12 @@ const config = {
|
|||||||
format: 'esm',
|
format: 'esm',
|
||||||
},
|
},
|
||||||
plugins: [
|
plugins: [
|
||||||
|
replace({
|
||||||
|
preventAssignment: true, // // 避免替换时发生意外赋值
|
||||||
|
DEV_SERVER: JSON.stringify(isDev), // DEV_SERVE
|
||||||
|
EXPORT_APP: JSON.stringify(exportApp), // 是否内联应用
|
||||||
|
EXPORT_PORT: JSON.stringify(3006), // 导出端口
|
||||||
|
}),
|
||||||
alias({
|
alias({
|
||||||
// only esbuild needs to be configured
|
// only esbuild needs to be configured
|
||||||
entries: [
|
entries: [
|
||||||
@ -54,7 +64,7 @@ const config = {
|
|||||||
esbuild({
|
esbuild({
|
||||||
target: 'node22', // 目标为 Node.js 14
|
target: 'node22', // 目标为 Node.js 14
|
||||||
minify: false, // 启用代码压缩
|
minify: false, // 启用代码压缩
|
||||||
tsconfig: 'tsconfig.json'
|
tsconfig: 'tsconfig.json',
|
||||||
}),
|
}),
|
||||||
// typescript({
|
// typescript({
|
||||||
// declaration: false,
|
// declaration: false,
|
||||||
|
@ -27,7 +27,12 @@ app
|
|||||||
ctx.body = services;
|
ctx.body = services;
|
||||||
})
|
})
|
||||||
.addTo(app);
|
.addTo(app);
|
||||||
|
// @ts-ignore
|
||||||
|
|
||||||
app.listen(3006, () => {
|
console.log('DEV_SERVER', DEV_SERVER == false);
|
||||||
console.log('pm2-manage is running on', `http://localhost:3006`);
|
// @ts-ignore
|
||||||
});
|
if (DEV_SERVER || !EXPORT_APP) {
|
||||||
|
app.listen(3006, () => {
|
||||||
|
console.log('pm2-manage is running on', `http://localhost:3006`);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user