From 4e296c1555ef3ef36b05f7054e426156f35b5511 Mon Sep 17 00:00:00 2001 From: Tian Dai Date: Tue, 4 Jun 2024 16:16:36 +0900 Subject: [PATCH] =?UTF-8?q?npm-run-all2=E3=82=92=E5=85=A8=E3=82=AA?= =?UTF-8?q?=E3=83=9A=E3=83=AC=E3=83=BC=E3=83=86=E3=82=A3=E3=83=B3=E3=82=B0?= =?UTF-8?q?=E3=83=BB=E3=82=B7=E3=82=B9=E3=83=86=E3=83=A0=E3=81=A8=E4=BE=9D?= =?UTF-8?q?=E5=AD=98=E6=80=A7=E7=AE=A1=E7=90=86=E3=81=AE=E3=82=B5=E3=83=9D?= =?UTF-8?q?=E3=83=BC=E3=83=88=E3=81=AB=E7=BD=AE=E3=81=8D=E6=8F=9B=E3=81=88?= =?UTF-8?q?=E3=82=8B=E3=80=82=E3=83=A9=E3=83=B3=E3=83=BB=E3=82=B9=E3=82=AF?= =?UTF-8?q?=E3=83=AA=E3=83=97=E3=83=88=E3=82=92=E3=82=88=E3=82=8A=E7=B5=84?= =?UTF-8?q?=E3=81=BF=E5=90=88=E3=82=8F=E3=81=9B=E5=8F=AF=E8=83=BD=E3=81=AA?= =?UTF-8?q?=E3=82=82=E3=81=AE=E3=81=AB=E5=86=8D=E7=B7=A8=E6=88=90=E3=81=99?= =?UTF-8?q?=E3=82=8B=E3=80=82=20=E3=83=97=E3=83=AD=E3=82=B8=E3=82=A7?= =?UTF-8?q?=E3=82=AF=E3=83=88=E3=81=AE=20dotenv=20=E3=82=B5=E3=83=9D?= =?UTF-8?q?=E3=83=BC=E3=83=88=E3=82=92=E6=8F=90=E4=BE=9B=E3=81=99=E3=82=8B?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugin/kintone-addins/.env.dev | 2 ++ plugin/kintone-addins/.env.production | 2 ++ plugin/kintone-addins/package.json | 26 +++++++++------ plugin/kintone-addins/vite.config.js | 48 ++++++++++++++------------- 4 files changed, 44 insertions(+), 34 deletions(-) create mode 100644 plugin/kintone-addins/.env.dev create mode 100644 plugin/kintone-addins/.env.production diff --git a/plugin/kintone-addins/.env.dev b/plugin/kintone-addins/.env.dev new file mode 100644 index 0000000..ffd5efa --- /dev/null +++ b/plugin/kintone-addins/.env.dev @@ -0,0 +1,2 @@ +VITE_SOURCE_MAP = inline +VITE_PORT = 4173 \ No newline at end of file diff --git a/plugin/kintone-addins/.env.production b/plugin/kintone-addins/.env.production new file mode 100644 index 0000000..e06147a --- /dev/null +++ b/plugin/kintone-addins/.env.production @@ -0,0 +1,2 @@ +VITE_SOURCE_MAP = false +VITE_PORT = 4173 \ No newline at end of file diff --git a/plugin/kintone-addins/package.json b/plugin/kintone-addins/package.json index 590f2f3..2e06d41 100644 --- a/plugin/kintone-addins/package.json +++ b/plugin/kintone-addins/package.json @@ -4,21 +4,25 @@ "version": "0.0.0", "type": "module", "scripts": { - "dev": "tsc && set \"SOURCE_MAP=true\" && vite build && vite preview", - "build": "tsc && vite build && xcopy dist\\*.js ..\\..\\backend\\Temp\\ /E /I /Y", - "build:linux": "tsc && vite build && cp -ur dist/*.js ../../backend/Temp", - "build:dev": "tsc && set \"SOURCE_MAP=true\" && vite build && xcopy dist\\*.js ..\\..\\backend\\Temp\\ /E /I /Y", - "preview": "vite preview", - "ngrok": "ngrok http http://localhost:4173/", - "vite": "vite dev", - "server": "vite dev & ngrok http 4173", - "watch": "vite build --watch", - "test": "run-p watch server" + "dev": "run-p watch server ngrok", + "watch": "vite build --watch --mode dev", + "server": "vite server", + "ngrok": "ngrok http 4173", + + "build": "run-s b:production copy:windows", + "build:dev": "run-s b:dev copy:windows", + "build:linux": "run-s b:production copy:linux", + "build:linux-dev": "run-s b:dev copy:linux", + + "b:production": "vite build --mode production", + "b:dev": "vite build --mode dev", + "copy:windows": "xcopy dist\\*.js ..\\..\\backend\\Temp\\ /E /I /Y", + "copy:linux": "cp -ur dist/*.js ../../backend/Temp" }, "devDependencies": { "@types/jquery": "^3.5.24", "@types/node": "^20.8.9", - "npm-run-all": "^4.1.5", + "npm-run-all2": "^6.2.0", "sass": "^1.69.5", "typescript": "^5.0.2", "vite": "^4.4.5", diff --git a/plugin/kintone-addins/vite.config.js b/plugin/kintone-addins/vite.config.js index 5750db8..7b2e9ad 100644 --- a/plugin/kintone-addins/vite.config.js +++ b/plugin/kintone-addins/vite.config.js @@ -1,30 +1,32 @@ // vite.config.js -import { defineConfig } from "vite"; +import { defineConfig, loadEnv } from "vite"; import cssInjectedByJsPlugin from "vite-plugin-css-injected-by-js"; import checker from "vite-plugin-checker"; -const sourcemap = process.env.SOURCE_MAP === "true"; +export default ({ mode }) => { + process.env = { ...process.env, ...loadEnv(mode, process.cwd()) }; -export default defineConfig({ - plugins: [ - checker({ - typescript: true, - }), - cssInjectedByJsPlugin(), - ], - build: { - cssCodeSplit: false, - rollupOptions: { - input: "src/index.ts", // entry file - output: { - entryFileNames: "alc_runtime.js", - // assetFileNames:'alc_kintone_style.css' + return defineConfig({ + plugins: [ + checker({ + typescript: true, + }), + cssInjectedByJsPlugin(), + ], + build: { + cssCodeSplit: false, + rollupOptions: { + input: "src/index.ts", // entry file + output: { + entryFileNames: "alc_runtime.js", + // assetFileNames:'alc_kintone_style.css' + }, }, + sourcemap: process.env.VITE_SOURCE_MAP, }, - sourcemap: sourcemap, - }, - server: { - port: 4173, - open: '/dist/alc_runtime.js', - } -}); + server: { + port: process.env.VITE_PORT, + open: "/dist/alc_runtime.js", + }, + }); +};