Skip to content

Commit

Permalink
fix(builder): should generate manifest correctly when enable SSR (#4990)
Browse files Browse the repository at this point in the history
  • Loading branch information
chenjiahan committed Nov 23, 2023
1 parent 9016367 commit fc1f36f
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 5 deletions.
6 changes: 6 additions & 0 deletions .changeset/eighty-beans-serve.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@modern-js/builder-webpack-provider': patch
'@modern-js/builder-rspack-provider': patch
---

fix(builder): should generate manifest correctly when enable SSR
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export const builderPluginManifest = (): BuilderPlugin => ({
name: 'builder-plugin-manifest',

setup(api) {
api.modifyBundlerChain(async (chain, { CHAIN_ID }) => {
api.modifyBundlerChain(async (chain, { CHAIN_ID, target }) => {
const config = api.getNormalizedConfig();

if (!config.output.enableAssetManifest) {
Expand All @@ -17,7 +17,10 @@ export const builderPluginManifest = (): BuilderPlugin => ({

chain.plugin(CHAIN_ID.PLUGIN.MANIFEST).use(WebpackManifestPlugin, [
{
fileName: 'asset-manifest.json',
fileName:
target === 'web'
? 'asset-manifest.json'
: `asset-manifest-${target}.json`,
publicPath,
generate: generateManifest,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export const builderPluginManifest = (): BuilderPlugin => ({
name: 'builder-plugin-manifest',

setup(api) {
api.modifyWebpackChain(async (chain, { CHAIN_ID }) => {
api.modifyWebpackChain(async (chain, { CHAIN_ID, target }) => {
const config = api.getNormalizedConfig();

if (!config.output.enableAssetManifest) {
Expand All @@ -19,7 +19,10 @@ export const builderPluginManifest = (): BuilderPlugin => ({

chain.plugin(CHAIN_ID.PLUGIN.MANIFEST).use(WebpackManifestPlugin, [
{
fileName: 'asset-manifest.json',
fileName:
target === 'web'
? 'asset-manifest.json'
: `asset-manifest-${target}.json`,
publicPath,
generate: generateManifest,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,8 @@ After compiler, there will be a `dist/manifest.json` file:
"entrypoints": ["static/css/main.45b01211.css", "static/js/main.52fd298f.js"]
}
```

If the current project has multiple types of build artifacts, such as including SSR build artifacts, multiple manifest.json files will be generated.

- web artifact: `asset-manifest.json`
- node artifact: `asset-manifest-node.json`
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export default {
};
```

开启后,当编译完成时,会自动生成 `dist/manifest.json` 文件:
开启后,当编译完成时,会自动生成 `dist/asset-manifest.json` 文件:

```json
{
Expand All @@ -27,3 +27,8 @@ export default {
"entrypoints": ["static/css/main.45b01211.css", "static/js/main.52fd298f.js"]
}
```

如果当前项目有多种类型构建产物,比如包含了 SSR 构建产物,那么会生成多份 manifest.json 文件。

- web 产物:`asset-manifest.json`
- node 产物:`asset-manifest-node.json`

0 comments on commit fc1f36f

Please sign in to comment.