From d527f5183d31ea5a0db43d4b988b9567d1cb7028 Mon Sep 17 00:00:00 2001 From: Benson Cho Date: Sat, 20 Apr 2024 20:48:10 +0800 Subject: [PATCH] add version in the background --- src/index.html | 1 + src/index.ts | 4 ++-- webpack.config.js | 5 +++++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/index.html b/src/index.html index f533568..af3e257 100644 --- a/src/index.html +++ b/src/index.html @@ -91,6 +91,7 @@ +
分數: 0
Combo: 0
diff --git a/src/index.ts b/src/index.ts index facf318..84ce3af 100644 --- a/src/index.ts +++ b/src/index.ts @@ -242,7 +242,7 @@ type CubeAndType={ initEvent() // fillOneRect(0,5,colorSet.red); set.startX = Math.round(set.grid_cols/2) - + $('input[name="version"]').val( process.env.VERSION||""); start() } const setValue = function(key:string, val:any) { @@ -858,7 +858,7 @@ type CubeAndType={ setValue } } - + const pageController = PageController() pageController.init() })() diff --git a/webpack.config.js b/webpack.config.js index 40b71df..37d64b2 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -3,6 +3,8 @@ const isProduction = process.env.NODE_ENV == "production"; const CopyPlugin = require('copy-webpack-plugin'); const { CleanWebpackPlugin } = require('clean-webpack-plugin'); const HtmlWebpackPlugin = require('html-webpack-plugin'); +const { DefinePlugin } = require('webpack'); +const packageJson = require('./package.json'); const config = { entry: "./src/index.ts", @@ -40,6 +42,9 @@ const config = { template: './src/index.html', // HTML 模板文件路径 chunks: ['index'], // 指定注入的 JavaScript 文件名 }), + new DefinePlugin({ + 'process.env.VERSION': JSON.stringify(packageJson.version), + }), ], };