Skip to content

Commit

Permalink
fix: use dynamic publicPath for web component bundles (fix #949)
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 committed Mar 6, 2018
1 parent 2549257 commit f744040
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,10 @@ module.exports = (api, { target, entry, name }) => {
config.output
.filename(`${entryName}.js`)
.chunkFilename(`${libName}.[id]${minify ? `.min` : ``}.js`)
// use relative publicPath so this can be deployed anywhere
.publicPath('./')
// use dynamic publicPath so this can be deployed anywhere
// the actual path will be determined at runtime by checking
// document.currentScript.src.
.publicPath('')

// externalize Vue in case user imports it
config
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,13 @@ import 'css-loader/lib/css-base'
import 'vue-style-loader/lib/addStylesShadow'
import 'vue-loader/lib/runtime/component-normalizer'
;(() => {
let i
if ((i = document.currentScript) && (i = i.src.match(/(.+\\/)[^/]+\\.js$/))) {
__webpack_public_path__ = i[1]
}
})()
${files.map(file => {
const { camelName, kebabName } = exports.fileToComponentName(prefix, file)
return async
Expand Down

0 comments on commit f744040

Please sign in to comment.