Skip to content

Commit

Permalink
fix: make ssr-build-plugin compatible with webpack4/5 (fix vuejs#11718)
Browse files Browse the repository at this point in the history
  • Loading branch information
lduoduo committed Dec 9, 2020
1 parent b641e1b commit 7b1e90a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/server/template-renderer/index.js
Expand Up @@ -55,7 +55,7 @@ export default class TemplateRenderer {
this.inject = options.inject !== false
// if no template option is provided, the renderer is created
// as a utility object for rendering assets like preload links and scripts.

const { template } = options
this.parsedTemplate = template
? typeof template === 'string'
Expand Down Expand Up @@ -224,7 +224,7 @@ export default class TemplateRenderer {
if (this.clientManifest) {
const initial = this.preloadFiles.filter(({ file }) => isJS(file))
const async = (this.getUsedAsyncFiles(context) || []).filter(({ file }) => isJS(file))
const needed = [initial[0]].concat(async, initial.slice(1))
const needed = [].concat(initial[0] ? [initial[0]] : [], async, initial.slice(1));
return needed.map(({ file }) => {
return `<script src="${this.publicPath}${file}" defer></script>`
}).join('')
Expand Down
3 changes: 3 additions & 0 deletions src/server/webpack-plugin/server.js
Expand Up @@ -59,6 +59,9 @@ export default class VueSSRServerPlugin {
stats.assets.forEach(asset => {
if (isJS(asset.name)) {
bundle.files[asset.name] = compilation.assets[asset.name].source()
if (asset.info && asset.info.related && asset.info.related.sourceMap) {
bundle.maps[asset.info.related.sourceMap.replace(/\.map$/, '')] = JSON.parse(compilation.assets[asset.info.related.sourceMap].source());
}
} else if (asset.name.match(/\.js\.map$/)) {
bundle.maps[asset.name.replace(/\.map$/, '')] = JSON.parse(compilation.assets[asset.name].source())
}
Expand Down

0 comments on commit 7b1e90a

Please sign in to comment.