Skip to content

Commit 8ca0b57

Browse files
committed
use rolldown hooks
1 parent e19772f commit 8ca0b57

File tree

1 file changed

+27
-27
lines changed

1 file changed

+27
-27
lines changed

src/generators/web/build/css.mjs

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -17,33 +17,33 @@ export default () => {
1717
return {
1818
name: 'css-loader',
1919

20-
/**
21-
* Handles loading and transforming CSS module files
22-
* @param {string} id - The file path being loaded
23-
*/
24-
async load(id) {
25-
if (!id.endsWith('.module.css')) {
26-
return null;
27-
}
28-
29-
const source = await readFile(id, 'utf8');
30-
31-
const { code, exports } = await bundleAsync({
32-
filename: id,
33-
code: Buffer.from(source),
34-
cssModules: true,
35-
});
36-
37-
cssChunks.add(code.toString());
38-
39-
const mappedExports = Object.fromEntries(
40-
Object.entries(exports).map(([k, v]) => [k, v.name])
41-
);
42-
43-
return {
44-
code: `export default ${JSON.stringify(mappedExports)};`,
45-
moduleType: 'js',
46-
};
20+
load: {
21+
filter: {
22+
id: {
23+
include: /\.module\.css$/,
24+
},
25+
},
26+
/** @param {string} id */
27+
async handler(id) {
28+
const source = await readFile(id, 'utf8');
29+
30+
const { code, exports } = await bundleAsync({
31+
filename: id,
32+
code: Buffer.from(source),
33+
cssModules: true,
34+
});
35+
36+
cssChunks.add(code.toString());
37+
38+
const mappedExports = Object.fromEntries(
39+
Object.entries(exports).map(([k, v]) => [k, v.name])
40+
);
41+
42+
return {
43+
code: `export default ${JSON.stringify(mappedExports)};`,
44+
moduleType: 'js',
45+
};
46+
},
4747
},
4848

4949
/**

0 commit comments

Comments
 (0)