Skip to content

Commit

Permalink
feat: 環境整理
Browse files Browse the repository at this point in the history
* ビルドスクリプト
* tsconfig
* vite.config
* 上記各設定を、Nagarjunaとできるだけ揃える
  • Loading branch information
kochizufan committed Dec 14, 2024
1 parent b920695 commit dbd4f61
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 21 deletions.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2021 Code for History
Copyright (c) 2021-2024 Code for History

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
12 changes: 7 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
{
"name": "harumi",
"description": "Harumi (春海): Japanese-Western calendar open data and web converter",
"version": "0.1.4",
"version": "0.1.5",
"type": "module",
"private": false,
"main": "./dist/harumi.umd.cjs",
"module": "./dist/harumi.js",
"types": "./dist/index.d.ts",
Expand All @@ -15,12 +16,13 @@
},
"files": [
"dist",
"src"
"LICENSE",
"README.md"
],
"scripts": {
"dev": "vite",
"build": "cross-env BUILD_MODE=package tsc && vite build",
"deploy": "tsc && vite build",
"build": "tsc && cross-env BUILD_MODE=package vite build",
"deploy": "cp public/index.html index.html && tsc && vite build",
"preview": "vite preview",
"test": "vitest run",
"test:watch": "vitest",
Expand All @@ -37,7 +39,7 @@
"converter"
],
"readme": "README.md",
"author": "Kohei Otsuka ([email protected])",
"author": "Code for History",
"license": "MIT",
"bugs": {
"url": "https://github.com/code4history/Harumi/issues"
Expand Down
2 changes: 1 addition & 1 deletion public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ <h1 class="display-3"><span class="genkai">春海</span>: 年号推定フォー
</div>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/tWtIaxVXM" crossorigin="anonymous"></script>
<!-- デモ用スクリプト -->
<script type="module" src="./harumi.demo.js"></script>
<script type="module" src="./src/demo.ts"></script>
<!-- Service Worker の登録 -->
<script>
window.addEventListener('load', function() {
Expand Down
37 changes: 23 additions & 14 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,31 +12,40 @@ const packageJson = JSON.parse(
const isPackageBuild = process.env.BUILD_MODE === 'package';

export default defineConfig({
build: {
lib: isPackageBuild
? {
entry: resolve(__dirname, 'src/index.ts'),
name: 'Harumi',
fileName: 'harumi'
}
: {
build: isPackageBuild
? {
lib: {
entry: {
'harumi': resolve(__dirname, 'src/index.ts'),
'harumi.demo': resolve(__dirname, 'src/demo.ts')
'index': resolve(__dirname, 'src/index.ts'),
},
formats: ['es']
}
},
}
: {
outDir: 'dist',
emptyOutDir: true,
rollupOptions: {
input: {
main: resolve(__dirname, 'index.html')
},
output: {
entryFileNames: 'assets/[name].[hash].js',
chunkFileNames: 'assets/[name].[hash].js',
assetFileNames: 'assets/[name].[hash][extname]'
}
}
},
plugins: [dts()],
json: {
stringify: true // JSONをstringifyして含める
},
server: {
port: 8888, // 既存のwebpack devServerと同じポート
open: true // 起動時にブラウザを開く
port: 5174,
open: true,
strictPort: true
},
publicDir: 'public',
appType: 'spa', // SPAとして扱う
appType: 'spa',
define: {
'import.meta.env.APP_VERSION': JSON.stringify(packageJson.version)
}
Expand Down

0 comments on commit dbd4f61

Please sign in to comment.