cssとjsを1つのファイルにまとめるためのviteプラグインを追加。

This commit is contained in:
Mouriya
2024-05-13 16:11:52 +09:00
parent a7078b54c5
commit b25c17ab53
6 changed files with 56 additions and 38 deletions

View File

@@ -6,19 +6,22 @@
"scripts": { "scripts": {
"dev": "tsc && set \"SOURCE_MAP=true\" && vite build && vite preview", "dev": "tsc && set \"SOURCE_MAP=true\" && vite build && vite preview",
"build": "tsc && vite build && xcopy dist\\*.js ..\\..\\backend\\Temp\\ /E /I /Y", "build": "tsc && vite build && xcopy dist\\*.js ..\\..\\backend\\Temp\\ /E /I /Y",
"build:dev":"tsc && set \"SOURCE_MAP=true\" && 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", "preview": "vite preview",
"ngrok":"ngrok http http://localhost:4173/", "ngrok": "ngrok http http://localhost:4173/",
"vite":"vite dev" "vite": "vite dev"
}, },
"devDependencies": { "devDependencies": {
"@types/jquery": "^3.5.24", "@types/jquery": "^3.5.24",
"@types/node": "^20.8.9", "@types/node": "^20.8.9",
"sass": "^1.69.5", "sass": "^1.69.5",
"typescript": "^5.0.2", "typescript": "^5.0.2",
"vite": "^4.4.5" "vite": "^4.4.5",
"vite-plugin-checker": "^0.6.4"
}, },
"dependencies": { "dependencies": {
"jquery": "^3.7.1" "jquery": "^3.7.1",
"vite-plugin-css-injected-by-js": "^3.5.1"
} }
} }

View File

@@ -0,0 +1,24 @@
.alc-button-normal {
display: inline-block;
box-sizing: border-box;
padding: 0 16px;
margin-left: 16px;
margin-top: 8px;
min-width: 100px;
outline: none;
border: 1px solid #e3e7e8;
background-color: #f7f9fa;
box-shadow: 1px 1px 1px #fff inset;
color: #3498db;
text-align: center;
line-height: 32px;
}
.alc-button-normal:hover {
background-color: #c8d6dd;
box-shadow: none;
cursor: pointer;
}
.alc-button-normal:active {
color: #f7f9fa;
background-color: #54b8eb;
}

View File

@@ -2,6 +2,7 @@
import { actionAddins } from "."; import { actionAddins } from ".";
import { IField, IAction,IActionResult, IActionNode, IActionProperty, IContext } from "../types/ActionTypes"; import { IField, IAction,IActionResult, IActionNode, IActionProperty, IContext } from "../types/ActionTypes";
import { Formatter } from "../util/format"; import { Formatter } from "../util/format";
import "./auto-numbering.css";
declare global { declare global {
interface Window { $format: any; } interface Window { $format: any; }
@@ -84,6 +85,7 @@ export class AutoNumbering implements IAction{
execEval(match:string,expr:string):string{ execEval(match:string,expr:string):string{
console.log(match); console.log(match);
// @ts-ignore
return eval(expr); return eval(expr);
} }

View File

@@ -2,6 +2,8 @@
import { actionAddins } from "."; import { actionAddins } from ".";
import $ from 'jquery'; import $ from 'jquery';
import { IAction, IActionProperty, IActionNode, IActionResult } from "../types/ActionTypes"; import { IAction, IActionProperty, IActionNode, IActionResult } from "../types/ActionTypes";
import "./button-add.css";
/** /**
* ボタン配置属性定義 * ボタン配置属性定義
*/ */
@@ -51,30 +53,7 @@ export class ButtonAddAction implements IAction {
if(!menuSpace) return result; if(!menuSpace) return result;
if($("style#alc-button-add").length===0){ if($("style#alc-button-add").length===0){
const css=` const css=`
.alc-button-normal { `;
display: inline-block;
box-sizing: border-box;
padding: 0 16px;
margin-left: 16px;
margin-top: 8px;
min-width: 100px;
outline: none;
border: 1px solid #e3e7e8;
background-color: #f7f9fa;
box-shadow: 1px 1px 1px #fff inset;
color: #3498db;
text-align: center;
line-height: 32px;
}
.alc-button-normal:hover {
background-color: #c8d6dd;
box-shadow: none;
cursor: pointer;
}
.alc-button-normal:active {
color: #f7f9fa;
background-color: #54b8eb;
}`;
const style = $("<style id='alc-button-add'>/<style>"); const style = $("<style id='alc-button-add'>/<style>");
style.text(css); style.text(css);
$("head").append(style); $("head").append(style);

View File

@@ -1,16 +1,26 @@
// vite.config.js // vite.config.js
import { defineConfig } from 'vite' import { defineConfig } from "vite";
const sourcemap = process.env.SOURCE_MAP==='true'; import cssInjectedByJsPlugin from "vite-plugin-css-injected-by-js";
import checker from "vite-plugin-checker";
const sourcemap = process.env.SOURCE_MAP === "true";
export default defineConfig({ export default defineConfig({
plugins: [
checker({
typescript: true,
}),
cssInjectedByJsPlugin(),
],
build: { build: {
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:sourcemap sourcemap: sourcemap,
} },
}) });