Skip to content

Commit 7a3a5e6

Browse files
authored
Various updates (#117)
* fix: remove '~' prefix to support css-loader style import * fix: ignore vite processed files in src attr transform * fix: set config.base from BASE_URL env var * chore: add changeset * fix: inconsistent test * fix: test snapshot hash replacement * chore: update readme
1 parent 90cca62 commit 7a3a5e6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+895
-35
lines changed

.changeset/bright-bags-draw.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@marko/vite": patch
3+
---
4+
5+
Support css-loader imports, limit relative src attribute transforms, support BASE_URL env var

README.md

+7-1
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,12 @@ export default defineConfig({
4949
});
5050
```
5151

52+
# Base paths
53+
54+
When deploying an application under a nested public path, use Vite's [`base` option](https://vitejs.dev/config/shared-options.html#base) to specify a path to prefix all assets. This option can also be specified with the `BASE_URL` environment variable.
55+
56+
If the base path is not static, see the [basePathVar](#optionsbasepathvar) option for handling more advanced cases.
57+
5258
# Browser asset references
5359

5460
With @marko/vite when a _static relative path_ is used for certain native tag attributes, the relative asset will be imported and processed by Vite.
@@ -62,7 +68,7 @@ As an example, with the following template, the `logo.svg` will be imported and
6268
<img src="/assets/logo-TwEWmgMb.svg">
6369
```
6470

65-
You can see the list of elements and their attributes which are processed [here](./src/relative-assets-transform.ts).
71+
Most common image, media, and font filetypes are transformed automatically but some file types such as `.js` and `.css` files will not be. Generally these should be imported directly and not rendered as markup. To force the transformation of a path, add `?url` to it. You can see the list of elements and their attributes which are processed [here](./src/relative-assets-transform.ts).
6672

6773
# Linked Mode
6874

package-lock.json

+167
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
"fixpack": "^4.0.0",
3535
"husky": "^9.0.11",
3636
"jsdom": "^24.0.0",
37+
"less": "^4.2.0",
3738
"lint-staged": "^15.2.2",
3839
"marko": "^5.32.13",
3940
"mocha": "^10.3.0",
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<div
2+
id="implicit"
3+
>
4+
<div
5+
id="clickable"
6+
>
7+
Mounted: false Clicks: 0
8+
<img
9+
alt="logo"
10+
src="/some/base/path/assets/logo-[hash].svg"
11+
/>
12+
</div>
13+
</div>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<div
2+
id="implicit"
3+
>
4+
<div
5+
id="clickable"
6+
>
7+
Mounted: true Clicks: 0
8+
<img
9+
alt="logo"
10+
src="/some/base/path/assets/logo-[hash].svg"
11+
/>
12+
</div>
13+
</div>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<div
2+
id="implicit"
3+
>
4+
<div
5+
id="clickable"
6+
>
7+
Mounted: true Clicks: 1
8+
<img
9+
alt="logo"
10+
src="/some/base/path/assets/logo-[hash].svg"
11+
/>
12+
</div>
13+
</div>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<div
2+
id="implicit"
3+
>
4+
<div
5+
id="clickable"
6+
>
7+
Mounted: false Clicks: 0
8+
<img
9+
alt="logo"
10+
src="/some/base/path/src/components/logo.svg"
11+
/>
12+
</div>
13+
</div>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<div
2+
id="implicit"
3+
>
4+
<div
5+
id="clickable"
6+
>
7+
Mounted: true Clicks: 0
8+
<img
9+
alt="logo"
10+
src="/some/base/path/src/components/logo.svg"
11+
/>
12+
</div>
13+
</div>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<div
2+
id="implicit"
3+
>
4+
<div
5+
id="clickable"
6+
>
7+
Mounted: true Clicks: 1
8+
<img
9+
alt="logo"
10+
src="/some/base/path/src/components/logo.svg"
11+
/>
12+
</div>
13+
</div>

0 commit comments

Comments
 (0)