| @@ -69,6 +69,8 @@ const getCallbackFillAmount = (record: 入金予定結果) => { | |||||
| }; | }; | ||||
| (() => { | (() => { | ||||
| console.info("script build at " + process.env.BUILD_TIME); | |||||
| kintone.events.on("app.record.detail.show", (event) => { | kintone.events.on("app.record.detail.show", (event) => { | ||||
| const currentRecord = event.record as 入金予定結果; | const currentRecord = event.record as 入金予定結果; | ||||
| @@ -110,6 +110,8 @@ const getCallBackHandleFinish = (currentRecord: 定期予約選考) => { | |||||
| }; | }; | ||||
| (() => { | (() => { | ||||
| console.info("script build at " + process.env.BUILD_TIME); | |||||
| const events = ["app.record.create.show", "app.record.edit.show"]; | const events = ["app.record.create.show", "app.record.edit.show"]; | ||||
| kintone.events.on(events, (event) => { | kintone.events.on(events, (event) => { | ||||
| const record = event.record as 定期予約選考; | const record = event.record as 定期予約選考; | ||||
| @@ -5,16 +5,18 @@ type MyPageApiResponse = { | |||||
| }; | }; | ||||
| export const getUrl = (apiId: MyPageApiID) => { | export const getUrl = (apiId: MyPageApiID) => { | ||||
| return [process.env.MYPAGE_BASE_URL ?? "", "api-from-kintone", apiId].join( | |||||
| "/" | |||||
| ); | |||||
| return [ | |||||
| process.env.VAR.MYPAGE_BASE_URL ?? "", | |||||
| "api-from-kintone", | |||||
| apiId, | |||||
| ].join("/"); | |||||
| }; | }; | ||||
| export const send = async (apiId: MyPageApiID, data: object) => { | export const send = async (apiId: MyPageApiID, data: object) => { | ||||
| const url = getUrl(apiId); | const url = getUrl(apiId); | ||||
| const sendData = { | const sendData = { | ||||
| ...data, | ...data, | ||||
| token: process.env.MYPAGE_TOKEN ?? "", | |||||
| token: process.env.VAR.MYPAGE_TOKEN ?? "", | |||||
| }; | }; | ||||
| console.info("MyPageAPICall", url, data); | console.info("MyPageAPICall", url, data); | ||||
| @@ -19,6 +19,7 @@ | |||||
| }, | }, | ||||
| "files": [ | "files": [ | ||||
| "./node_modules/@kintone/dts-gen/kintone.d.ts", | "./node_modules/@kintone/dts-gen/kintone.d.ts", | ||||
| "./types/env.d.ts", | |||||
| ], | ], | ||||
| "include": [ | "include": [ | ||||
| "src/**/*" | "src/**/*" | ||||
| @@ -0,0 +1,15 @@ | |||||
| declare global { | |||||
| namespace NodeJS { | |||||
| interface ProcessEnv { | |||||
| NODE_ENV: "development" | "production" | "test"; | |||||
| // 他の環境変数も追加できます | |||||
| VAR: { | |||||
| MYPAGE_BASE_URL: string; | |||||
| MYPAGE_TOKEN: string; | |||||
| }; | |||||
| BUILD_TIME: string; | |||||
| } | |||||
| } | |||||
| } | |||||
| export {}; | |||||
| @@ -6,9 +6,13 @@ const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin'); | |||||
| const TsconfigPathsPlugin = require('tsconfig-paths-webpack-plugin'); | const TsconfigPathsPlugin = require('tsconfig-paths-webpack-plugin'); | ||||
| const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin; | const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin; | ||||
| const Dotenv = require('dotenv-webpack'); | const Dotenv = require('dotenv-webpack'); | ||||
| const dotenv = require('dotenv'); | |||||
| const { format } = require('date-fns'); | |||||
| const basePath = path.resolve('src', 'apps'); | const basePath = path.resolve('src', 'apps'); | ||||
| const env = dotenv.config().parsed | |||||
| // basePath配下の各ディレクトリを複数のentryとする | // basePath配下の各ディレクトリを複数のentryとする | ||||
| const entries = glob.sync('**/index.+(js|ts|tsx)', { cwd: basePath }).reduce( | const entries = glob.sync('**/index.+(js|ts|tsx)', { cwd: basePath }).reduce( | ||||
| (prev, file) => ({ | (prev, file) => ({ | ||||
| @@ -63,7 +67,7 @@ module.exports = { | |||||
| filename: '[name].js', | filename: '[name].js', | ||||
| }, | }, | ||||
| plugins: [ | plugins: [ | ||||
| new Dotenv({ systemvars: true }), | |||||
| // new Dotenv({ systemvars: true }), | |||||
| new ForkTsCheckerWebpackPlugin(), | new ForkTsCheckerWebpackPlugin(), | ||||
| // new BundleAnalyzerPlugin(), | // new BundleAnalyzerPlugin(), | ||||
| { | { | ||||
| @@ -100,11 +104,10 @@ module.exports = { | |||||
| ); | ); | ||||
| }, | }, | ||||
| }, | }, | ||||
| // new webpack.DefinePlugin({ | |||||
| // 'process.env': { | |||||
| // "MYPAGE_BASE_URL": JSON.stringify(process.env.MYPAGE_BASE_URL), | |||||
| // "MYPAGE_TOKEN": JSON.stringify(process.env.MYPAGE_TOKEN), | |||||
| // } | |||||
| // }), | |||||
| new webpack.DefinePlugin({ | |||||
| 'process.env.VAR': JSON.stringify(env), | |||||
| 'process.env.BUILD_TIME': JSON.stringify(format(new Date(), 'yyyy-MM-dd HH:mm:ss')), | |||||
| }), | |||||
| ], | ], | ||||
| }; | }; | ||||