From 9408f41bd0c646eb3961de6122136c5d61dd18be Mon Sep 17 00:00:00 2001 From: yj_gu Date: Thu, 12 Oct 2023 17:02:25 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20content-hash=20=E6=A8=A1=E5=BC=8F?= =?UTF-8?q?=E9=87=87=E7=94=A8=20opt-in=EF=BC=8C=E5=90=91=E5=90=8E=E5=85=BC?= =?UTF-8?q?=E5=AE=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build/index.js | 4 ++++ config/config.defaults.js | 9 ++++++++- package.json | 2 +- project/build.js | 3 ++- 4 files changed, 15 insertions(+), 3 deletions(-) diff --git a/build/index.js b/build/index.js index 5df1a7b9..a916b906 100644 --- a/build/index.js +++ b/build/index.js @@ -25,6 +25,10 @@ module.exports = function build(options) { startWebpackForServer(config) ]) + if (!config.useContentHash) { + return + } + const staticPath = path.join(config.root, config.publish, config.static) const assetsPath = path.join(staticPath, config.assetsPath) const assets = require(assetsPath) diff --git a/config/config.defaults.js b/config/config.defaults.js index 67ac8946..bceb1cc2 100644 --- a/config/config.defaults.js +++ b/config/config.defaults.js @@ -290,5 +290,12 @@ module.exports = { * * 支持:(view: React.ReactElement) => Promise | string | Buffer | NodeJS.ReadableStream */ - serverRenderer: undefined + serverRenderer: undefined, + + /** + * useContentHash + * 使用 contenthash 作为静态资源的 hash + * 默认为 false + */ + useContentHash: false }; diff --git a/package.json b/package.json index 03d51ba7..cb69eacc 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "react-imvc", - "version": "2.10.9", + "version": "2.10.10", "description": "An Isomorphic MVC Framework", "main": "./index", "bin": { diff --git a/project/build.js b/project/build.js index 07cc549c..d25a0091 100644 --- a/project/build.js +++ b/project/build.js @@ -12,7 +12,8 @@ const config = { publish: '../project_publish', // 打包输出目录 gulp: { img: false - } + }, + useContentHash: true } async function main() {