Skip to content

Commit f744040

Browse files
committed
fix: use dynamic publicPath for web component bundles (fix #949)
1 parent 2549257 commit f744040

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

packages/@vue/cli-service/lib/commands/build/resolveWcConfig.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,10 @@ module.exports = (api, { target, entry, name }) => {
6868
config.output
6969
.filename(`${entryName}.js`)
7070
.chunkFilename(`${libName}.[id]${minify ? `.min` : ``}.js`)
71-
// use relative publicPath so this can be deployed anywhere
72-
.publicPath('./')
71+
// use dynamic publicPath so this can be deployed anywhere
72+
// the actual path will be determined at runtime by checking
73+
// document.currentScript.src.
74+
.publicPath('')
7375

7476
// externalize Vue in case user imports it
7577
config

packages/@vue/cli-service/lib/commands/build/resolveWcEntry.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,13 @@ import 'css-loader/lib/css-base'
3333
import 'vue-style-loader/lib/addStylesShadow'
3434
import 'vue-loader/lib/runtime/component-normalizer'
3535
36+
;(() => {
37+
let i
38+
if ((i = document.currentScript) && (i = i.src.match(/(.+\\/)[^/]+\\.js$/))) {
39+
__webpack_public_path__ = i[1]
40+
}
41+
})()
42+
3643
${files.map(file => {
3744
const { camelName, kebabName } = exports.fileToComponentName(prefix, file)
3845
return async

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy