Skip to content

Commit 9373a22

Browse files
authored
fix(cli-plugin-pwa): webpack5 warning for emitting manifest.json (#6277)
1 parent 0dccc4a commit 9373a22

File tree

1 file changed

+25
-21
lines changed

1 file changed

+25
-21
lines changed

packages/@vue/cli-plugin-pwa/lib/HtmlPwaPlugin.js

+25-21
Original file line numberDiff line numberDiff line change
@@ -183,27 +183,31 @@ module.exports = class HtmlPwaPlugin {
183183
})
184184

185185
if (!isHrefAbsoluteUrl(this.options.manifestPath)) {
186-
compiler.hooks.emit.tapAsync(ID, (data, cb) => {
187-
const {
188-
name,
189-
themeColor,
190-
manifestPath,
191-
manifestOptions
192-
} = this.options
193-
const publicOptions = {
194-
name,
195-
short_name: name,
196-
theme_color: themeColor
197-
}
198-
const outputManifest = JSON.stringify(
199-
Object.assign(publicOptions, defaultManifest, manifestOptions)
200-
)
201-
data.assets[manifestPath] = {
202-
source: () => outputManifest,
203-
size: () => outputManifest.length
204-
}
205-
cb(null, data)
206-
})
186+
compiler.hooks.compilation.tap(ID, compilation => {
187+
compilation.hooks.processAssets.tap(
188+
{name: ID, stage: 'PROCESS_ASSETS_STAGE_ADDITIONS'},
189+
assets => {
190+
const {
191+
name,
192+
themeColor,
193+
manifestPath,
194+
manifestOptions
195+
} = this.options
196+
const publicOptions = {
197+
name,
198+
short_name: name,
199+
theme_color: themeColor
200+
}
201+
const outputManifest = JSON.stringify(
202+
Object.assign(publicOptions, defaultManifest, manifestOptions)
203+
)
204+
assets[manifestPath] = {
205+
source: () => outputManifest,
206+
size: () => outputManifest.length,
207+
};
208+
},
209+
);
210+
});
207211
}
208212
}
209213
}

0 commit comments

Comments
 (0)