Replies: 1 comment
-
I have found that if I define them in the same file they will be replaced. I've solved the problem for the time being, but I hope it will be flexible. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
export const enum ShipType { /** 海防 */ DE = 1, /** 駆逐 */ DD = 2, ・・・ }
const ship_datas: Record<number, ShipData> = { 1:{"name":"睦月","type":ShipType.DD,"seek":4,"seek2":17,"na":0,"sg":2}・・・}
When I bundle this, I expect the following
1:{name:"睦月",type:2,seek:4,seek2:17,na:0,sg:2}
But in fact
1:{name:"睦月",type:Gd.DD,seek:4,seek2:17,na:0,sg:2}
In the js file output by vue-tsc, it is replaced by a number, so I suspected it could have come from esbuild specs or settings inside vite, but esbuild seemed to have solved this problem years ago. https://github.com/evanw/esbuild/releases/tag/v0.14.7
tsconfig.json
{ "compilerOptions": { "target": "esnext", "module": "esnext", "strict": true, "jsx": "preserve", "importHelpers": true, "moduleResolution": "node", "skipLibCheck": true, "esModuleInterop": true, "allowSyntheticDefaultImports": true, "sourceMap": true, "removeComments": true, "outDir": "./build", "strictFunctionTypes": true, "baseUrl": ".", "paths": { "@/*": [ "src/*" ] }, "lib": [ "esnext", "dom", "dom.iterable", "scripthost", "WebWorker" ] }, }
vite.config.ts
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import vuetify from 'vite-plugin-vuetify'
import { createHtmlPlugin } from 'vite-plugin-html'
import vueDevTools from 'vite-plugin-vue-devtools'
import { visualizer } from 'rollup-plugin-visualizer'
import { createSvgIconsPlugin } from 'vite-plugin-svg-icons'
import path from 'node:path';
export default defineConfig({
plugins: [
vue(),
vuetify(), // 必ずvue()より後に書く
vueDevTools(),
createHtmlPlugin({}),
createSvgIconsPlugin({
// SVGファイルを格納するディレクトリ
iconDirs: [path.resolve(process.cwd(), 'src/icons/svgs')],
symbolId: 'icon-[name]', // アイコンのIDを
icon-xxx
の形式にするcustomDomId: 'svg__icons__dom',
}),
visualizer({
filename: './dist/stats.html', // 出力ファイルのパス
template: 'flamegraph', // これ以外だとtreemapくらいかな listでjson出力
// open: true, // ビルド後に自動でブラウザで開く
}),
],
resolve: {
alias: {
'@': path.resolve(__dirname, './src'),
},
},
base: '/compass/',
optimizeDeps: {
exclude: [
'tests',
'patches',
], // 無視させる
},
build: {
minify: 'terser', // Terserを使用して圧縮
terserOptions: {
mangle: true, // 変数名などの圧縮
},
},
})
package.json
{ "name": "compass_sim", "private": true, "version": "2.0.0", "type": "module", "scripts": { "dev": "vite", "build": "vue-tsc -b && vite build", "preview": "vite preview", "rand-test": "vitest --run -t 'rand-test'", "route-test": "vitest --run -t 'route-test'", "data-test": "vitest --run -t 'data-test'", "tests": "vitest run", "postinstall": "patch-package", "dep": "depcheck", "lint": "biome lint" }, "dependencies": { "@biomejs/biome": "^1.9.4", "@types/cytoscape": "^3.21.8", "axios": "1.2.2", "big.js": "^6.2.2", "cytoscape": "^3.31.0", "gkcoi": "1.5.2", "lz-string": "^1.5.0", "pinia": "^3.0.0", "rollup-plugin-visualizer": "^5.14.0", "terser": "^5.39.0", "vite-plugin-html": "^3.2.2", "vite-plugin-vue-devtools": "^7.7.0", "vite-plugin-vuetify": "^2.0.4", "vue": "^3.5.13", "vuetify": "^3.7.6" }, "devDependencies": { "@types/big.js": "^6.2.2", "@types/node": "^22.10.5", "@vitejs/plugin-vue": "^5.2.1", "@vitest/ui": "^3.0.5", "@vue/test-utils": "^2.4.6", "jsdom": "^26.0.0", "patch-package": "^8.0.0", "typescript": "~5.6.2", "vite": "^6.0.5", "vite-plugin-svg-icons": "^2.0.1", "vitest": "^3.0.5", "vue-tsc": "^2.2.0" } }
Beta Was this translation helpful? Give feedback.
All reactions