Skip to content

Commit 19dc930

Browse files
authored
feat: support asset module (#684)
1 parent fc6cf37 commit 19dc930

File tree

77 files changed

+1313
-247
lines changed

Some content is hidden

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

77 files changed

+1313
-247
lines changed

examples/preact-component-bundle-false/rslib.config.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,6 @@ import { pluginSass } from '@rsbuild/plugin-sass';
33
import { defineConfig } from '@rslib/core';
44

55
export default defineConfig({
6-
source: {
7-
entry: {
8-
index: ['./src/**'],
9-
},
10-
},
116
lib: [
127
{
138
bundle: false,

examples/preact-component-bundle-false/src/components/CounterButton/index.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import type { FunctionComponent } from 'preact';
2+
import logo from '../../assets/logo.svg';
23
import styles from './index.module.scss';
34

45
interface CounterButtonProps {
@@ -10,7 +11,12 @@ export const CounterButton: FunctionComponent<CounterButtonProps> = ({
1011
onClick,
1112
label,
1213
}) => (
13-
<button type="button" className={styles.button} onClick={onClick}>
14+
<button
15+
type="button"
16+
className={`${styles.button} counter-button`}
17+
onClick={onClick}
18+
>
19+
<img src={logo} alt="react" />
1420
{label}
1521
</button>
1622
);

examples/preact-component-bundle-false/src/env.d.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,8 @@ declare module '*.module.scss' {
22
const classes: { [key: string]: string };
33
export default classes;
44
}
5+
6+
declare module '*.svg' {
7+
const url: string;
8+
export default url;
9+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
.counter-title {
2+
width: 100px;
3+
height: 100px;
4+
background: no-repeat url('./assets/logo.svg');
5+
background-size: cover;
6+
}
7+
18
.counter-text {
29
font-size: 50px;
310
}

examples/react-component-bundle-false/rslib.config.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,6 @@ import { pluginSass } from '@rsbuild/plugin-sass';
33
import { defineConfig } from '@rslib/core';
44

55
export default defineConfig({
6-
source: {
7-
entry: {
8-
index: ['./src/**'],
9-
},
10-
},
116
lib: [
127
{
138
format: 'esm',
@@ -32,7 +27,6 @@ export default defineConfig({
3227
],
3328
output: {
3429
target: 'web',
35-
assetPrefix: 'auto', // TODO: move this line to packages/core/src/asset/assetConfig.ts,
3630
},
3731
plugins: [pluginReact(), pluginSass()],
3832
});

examples/react-component-bundle-false/src/components/CounterButton/index.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import type React from 'react';
2+
import logo from '../../assets/logo.svg';
23
import styles from './index.module.scss';
34

45
interface CounterButtonProps {
@@ -10,7 +11,12 @@ export const CounterButton: React.FC<CounterButtonProps> = ({
1011
onClick,
1112
label,
1213
}) => (
13-
<button type="button" className={styles.button} onClick={onClick}>
14+
<button
15+
type="button"
16+
className={`${styles.button} counter-button`}
17+
onClick={onClick}
18+
>
19+
<img src={logo} alt="react" />
1420
{label}
1521
</button>
1622
);

examples/react-component-bundle-false/src/env.d.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,8 @@ declare module '*.module.scss' {
22
const classes: { [key: string]: string };
33
export default classes;
44
}
5+
6+
declare module '*.svg' {
7+
const url: string;
8+
export default url;
9+
}

examples/react-component-bundle/rslib.config.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ export default defineConfig({
2525
],
2626
output: {
2727
target: 'web',
28-
assetPrefix: 'auto', // TODO: move this line to packages/core/src/asset/assetConfig.ts
2928
},
3029
plugins: [pluginReact(), pluginSass()],
3130
});

examples/react-component-bundle/src/components/CounterButton/index.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import type React from 'react';
2+
import logo from '../../assets/logo.svg';
23
import styles from './index.module.scss';
34

45
interface CounterButtonProps {
@@ -10,7 +11,12 @@ export const CounterButton: React.FC<CounterButtonProps> = ({
1011
onClick,
1112
label,
1213
}) => (
13-
<button type="button" className={styles.button} onClick={onClick}>
14+
<button
15+
type="button"
16+
className={`${styles.button} counter-button`}
17+
onClick={onClick}
18+
>
19+
<img src={logo} alt="react" />
1420
{label}
1521
</button>
1622
);

0 commit comments

Comments
 (0)