Skip to content

Commit 7872415

Browse files
committed
wip: css
1 parent ec7892b commit 7872415

File tree

6 files changed

+34
-10
lines changed

6 files changed

+34
-10
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -563,7 +563,7 @@ export function cssPostPlugin(config: ResolvedConfig): RolldownPlugin {
563563
!inlined &&
564564
dataToEsm(modules, { namedExports: true, preferConst: true })
565565

566-
if (config.command === 'serve') {
566+
if (config.command === 'serve' && !config.experimental.rolldownDev) {
567567
const getContentWithSourcemap = async (content: string) => {
568568
if (config.css?.devSourcemap) {
569569
const sourcemap = this.getCombinedSourcemap()

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

Lines changed: 5 additions & 4 deletions
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

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ export function rolldownDevHandleConfig(
6868
// this is not "build" option any more (or is there a way to handle entry lazily?)
6969
build: {
7070
modulePreload: false,
71+
cssCodeSplit: false,
7172
rollupOptions: {
7273
input:
7374
config.build?.rollupOptions?.input ??
@@ -182,10 +183,16 @@ class RolldownEnvironment extends DevEnvironment {
182183
plugins = plugins.filter(
183184
(p) =>
184185
!(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),
186+
[
187+
'vite:define',
188+
'vite:build-html',
189+
'vite:build-metadata',
190+
'vite:css',
191+
'vite:css-post',
192+
].includes(p.name) ||
193+
['AliasPlugin', 'TransformPlugin', 'LoadFallbackPlugin'].includes(
194+
p.constructor.name,
195+
),
189196
)
190197
plugins = plugins.map((p) => injectEnvironmentToHooks(this as any, p))
191198

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

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

811
export function App() {
912
const [count, setCount] = React.useState(0)
@@ -17,8 +20,15 @@ export function App() {
1720
</button>
1821
<pre>[virtual] {virtualTest}</pre>
1922
<pre>[alias] {testAlias}</pre>
20-
{/* TODO: slightly broken probably due to patching rolldown:runtime during renderChunk */}
23+
{/* TODO: source map is slightly broken probably due to patching rolldown:runtime during renderChunk */}
2124
<button onClick={() => throwError()}>stacktrace</button>
25+
<pre>
26+
[css] <span className="test-style">orange</span>
27+
</pre>
28+
<style>{testStyleInline}</style>
29+
<pre>
30+
[css?inline] <span className="test-style-inline">orange</span>
31+
</pre>
2232
</div>
2333
</div>
2434
)
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.test-style-inline {
2+
color: orange;
3+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.test-style {
2+
color: orange;
3+
}

0 commit comments

Comments
 (0)