Skip to content

Commit

Permalink
fix: content-hash 模式采用 opt-in,向后兼容
Browse files Browse the repository at this point in the history
  • Loading branch information
Lucifier129 committed Oct 12, 2023
1 parent 0a7fe8a commit 9408f41
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 3 deletions.
4 changes: 4 additions & 0 deletions build/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
9 changes: 8 additions & 1 deletion config/config.defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -290,5 +290,12 @@ module.exports = {
*
* 支持:(view: React.ReactElement) => Promise<string | Buffer | NodeJS.ReadableStream> | string | Buffer | NodeJS.ReadableStream
*/
serverRenderer: undefined
serverRenderer: undefined,

/**
* useContentHash
* 使用 contenthash 作为静态资源的 hash
* 默认为 false
*/
useContentHash: false
};
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-imvc",
"version": "2.10.9",
"version": "2.10.10",
"description": "An Isomorphic MVC Framework",
"main": "./index",
"bin": {
Expand Down
3 changes: 2 additions & 1 deletion project/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ const config = {
publish: '../project_publish', // 打包输出目录
gulp: {
img: false
}
},
useContentHash: true
}

async function main() {
Expand Down

0 comments on commit 9408f41

Please sign in to comment.