Skip to content

Commit dd66ac2

Browse files
committed
wip: enable vite:asset
1 parent 7872415 commit dd66ac2

File tree

4 files changed

+14
-1
lines changed

4 files changed

+14
-1
lines changed

packages/vite/src/node/plugins/asset.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,10 @@ export async function fileToUrl(
275275
id: string,
276276
): Promise<string> {
277277
const { environment } = pluginContext
278-
if (environment.config.command === 'serve') {
278+
if (
279+
environment.config.command === 'serve' &&
280+
!environment.config.experimental.rolldownDev
281+
) {
279282
return fileToDevUrl(environment, id)
280283
} else {
281284
return fileToBuiltUrl(pluginContext, id)

packages/vite/src/node/server/environments/rolldown.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ export function rolldownDevHandleConfig(
6969
build: {
7070
modulePreload: false,
7171
cssCodeSplit: false,
72+
assetsInlineLimit: 0,
7273
rollupOptions: {
7374
input:
7475
config.build?.rollupOptions?.input ??
@@ -189,6 +190,7 @@ class RolldownEnvironment extends DevEnvironment {
189190
'vite:build-metadata',
190191
'vite:css',
191192
'vite:css-post',
193+
'vite:asset',
192194
].includes(p.name) ||
193195
['AliasPlugin', 'TransformPlugin', 'LoadFallbackPlugin'].includes(
194196
p.constructor.name,

playground/rolldown-dev-react/src/app.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import testAlias from 'test-alias'
66
import { throwError } from './error'
77
// TODO: hmr
88
import './test-style.css'
9+
import testStyleUrl from './test-style-url.css?url'
910
import testStyleInline from './test-style-inline.css?inline'
1011

1112
export function App() {
@@ -25,6 +26,10 @@ export function App() {
2526
<pre>
2627
[css] <span className="test-style">orange</span>
2728
</pre>
29+
<link rel="stylesheet" href={testStyleUrl} />
30+
<pre>
31+
[css?url] <span className="test-style-url">orange</span>
32+
</pre>
2833
<style>{testStyleInline}</style>
2934
<pre>
3035
[css?inline] <span className="test-style-inline">orange</span>
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.test-style-url {
2+
color: orange;
3+
}

0 commit comments

Comments
 (0)