Skip to content

Commit 5b48592

Browse files
committed
feat: wip css plugins
1 parent 8468d41 commit 5b48592

File tree

5 files changed

+32
-9
lines changed

5 files changed

+32
-9
lines changed

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

+5-4
Original file line numberDiff line numberDiff line change
@@ -45,19 +45,20 @@ export async function resolvePlugins(
4545
normalPlugins: Plugin[],
4646
postPlugins: Plugin[],
4747
): Promise<Plugin[]> {
48+
const rolldownDev = config.experimental.rolldownDev
4849
const isBuild = config.command === 'build'
4950
const isWorker = config.isWorker
50-
const buildPlugins = isBuild
51-
? await (await import('../build')).resolveBuildPlugins(config)
52-
: { pre: [], post: [] }
51+
const buildPlugins =
52+
isBuild || rolldownDev
53+
? await (await import('../build')).resolveBuildPlugins(config)
54+
: { pre: [], post: [] }
5355
const { modulePreload } = config.build
5456
const depOptimizationEnabled =
5557
!isBuild &&
5658
Object.values(config.environments).some(
5759
(environment) => !isDepOptimizationDisabled(environment.optimizeDeps),
5860
)
5961
const enableNativePlugin = config.experimental.enableNativePlugin
60-
const rolldownDev = config.experimental.rolldownDev
6162

6263
return [
6364
depOptimizationEnabled ? optimizedDepsPlugin() : null,

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

+10-4
Original file line numberDiff line numberDiff line change
@@ -182,10 +182,16 @@ class RolldownEnvironment extends DevEnvironment {
182182
plugins = plugins.filter(
183183
(p) =>
184184
!(typeof p.name === 'number' || p.name?.startsWith('vite:')) ||
185-
['vite:define', 'vite:build-html', 'vite:build-metadata'].includes(
186-
p.name,
187-
) ||
188-
['AliasPlugin', 'TransformPlugin'].includes(p.constructor.name),
185+
[
186+
'vite:define',
187+
'vite:build-html',
188+
'vite:build-metadata',
189+
'vite:css',
190+
'vite:css-post',
191+
].includes(p.name) ||
192+
['AliasPlugin', 'TransformPlugin', 'LoadFallbackPlugin'].includes(
193+
p.constructor.name,
194+
),
189195
)
190196
plugins = plugins.map((p) => injectEnvironmentToHooks(this as any, p))
191197

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

+11-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import virtualTest from 'virtual:test'
44
// @ts-expect-error no type
55
import testAlias from 'test-alias'
66
import { throwError } from './error'
7+
import './test-style.css'
8+
import testStyleInline from './test-style-inline.css?inline'
79

810
export function App() {
911
const [count, setCount] = React.useState(0)
@@ -17,8 +19,16 @@ export function App() {
1719
</button>
1820
<pre>[virtual] {virtualTest}</pre>
1921
<pre>[alias] {testAlias}</pre>
20-
{/* TODO: slightly broken probably due to patching rolldown:runtime during renderChunk */}
22+
{/* TODO: source map is slightly broken probably due to patching rolldown:runtime during renderChunk */}
2123
<button onClick={() => throwError()}>stacktrace</button>
24+
<style>{testStyleInline}</style>
25+
<pre>
26+
[css?inline] <span className="test-style-inline">orange</span>
27+
</pre>
28+
{/* TODO */}
29+
<pre>
30+
[css] <span className="test-style">orange</span>
31+
</pre>
2232
</div>
2333
</div>
2434
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.test-style-inline {
2+
color: orange;
3+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.test-style {
2+
color: orange;
3+
}

0 commit comments

Comments
 (0)