kopia lustrzana https://github.com/shoelace-style/shoelace
Fix asset path for Rails (#268)
The path to assets should be consistent and not depend on the current script source. There are at least two situations when this assumption fails: - When running `webpacker-dev-server`, the _pack_ URL doesn't contain `/js/` part. - In test environment, `/packs-test` is used by default.pull/481/head
rodzic
248f494865
commit
c7da2f24d5
|
@ -36,8 +36,13 @@ import { defineCustomElements, setAssetPath } from '@shoelace-style/shoelace'
|
|||
|
||||
// ...
|
||||
|
||||
const rootUrl = document.currentScript.src.replace(/\/packs.*$/, '')
|
||||
|
||||
// Path to the assets folder (should be independent on the current script source path
|
||||
// to work correctly in different environments)
|
||||
setAssetPath(rootUrl + '/packs/js/')
|
||||
|
||||
// This enables all web components for the current page
|
||||
setAssetPath(document.currentScript.src)
|
||||
defineCustomElements()
|
||||
```
|
||||
|
||||
|
|
Ładowanie…
Reference in New Issue