npm-run-all2を全オペレーティング・システムと依存性管理のサポートに置き換える。ラン・スクリプトをより組み合わせ可能なものに再編成する。 プロジェクトの dotenv サポートを提供する。

This commit is contained in:
Tian Dai
2024-06-04 16:16:36 +09:00
parent 6df72a1ae3
commit 4e296c1555
4 changed files with 44 additions and 34 deletions

View File

@@ -0,0 +1,2 @@
VITE_SOURCE_MAP = inline
VITE_PORT = 4173

View File

@@ -0,0 +1,2 @@
VITE_SOURCE_MAP = false
VITE_PORT = 4173

View File

@@ -4,21 +4,25 @@
"version": "0.0.0", "version": "0.0.0",
"type": "module", "type": "module",
"scripts": { "scripts": {
"dev": "tsc && set \"SOURCE_MAP=true\" && vite build && vite preview", "dev": "run-p watch server ngrok",
"build": "tsc && vite build && xcopy dist\\*.js ..\\..\\backend\\Temp\\ /E /I /Y", "watch": "vite build --watch --mode dev",
"build:linux": "tsc && vite build && cp -ur dist/*.js ../../backend/Temp", "server": "vite server",
"build:dev": "tsc && set \"SOURCE_MAP=true\" && vite build && xcopy dist\\*.js ..\\..\\backend\\Temp\\ /E /I /Y", "ngrok": "ngrok http 4173",
"preview": "vite preview",
"ngrok": "ngrok http http://localhost:4173/", "build": "run-s b:production copy:windows",
"vite": "vite dev", "build:dev": "run-s b:dev copy:windows",
"server": "vite dev & ngrok http 4173", "build:linux": "run-s b:production copy:linux",
"watch": "vite build --watch", "build:linux-dev": "run-s b:dev copy:linux",
"test": "run-p watch server"
"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": { "devDependencies": {
"@types/jquery": "^3.5.24", "@types/jquery": "^3.5.24",
"@types/node": "^20.8.9", "@types/node": "^20.8.9",
"npm-run-all": "^4.1.5", "npm-run-all2": "^6.2.0",
"sass": "^1.69.5", "sass": "^1.69.5",
"typescript": "^5.0.2", "typescript": "^5.0.2",
"vite": "^4.4.5", "vite": "^4.4.5",

View File

@@ -1,30 +1,32 @@
// vite.config.js // vite.config.js
import { defineConfig } from "vite"; import { defineConfig, loadEnv } from "vite";
import cssInjectedByJsPlugin from "vite-plugin-css-injected-by-js"; import cssInjectedByJsPlugin from "vite-plugin-css-injected-by-js";
import checker from "vite-plugin-checker"; 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({ return defineConfig({
plugins: [ plugins: [
checker({ checker({
typescript: true, typescript: true,
}), }),
cssInjectedByJsPlugin(), cssInjectedByJsPlugin(),
], ],
build: { build: {
cssCodeSplit: false, cssCodeSplit: false,
rollupOptions: { rollupOptions: {
input: "src/index.ts", // entry file input: "src/index.ts", // entry file
output: { output: {
entryFileNames: "alc_runtime.js", entryFileNames: "alc_runtime.js",
// assetFileNames:'alc_kintone_style.css' // assetFileNames:'alc_kintone_style.css'
},
}, },
sourcemap: process.env.VITE_SOURCE_MAP,
}, },
sourcemap: sourcemap, server: {
}, port: process.env.VITE_PORT,
server: { open: "/dist/alc_runtime.js",
port: 4173, },
open: '/dist/alc_runtime.js', });
} };
});