-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
200 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>Document</title> | ||
</head> | ||
<body> | ||
<div id="root"></div> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
{ | ||
"name": "example-react", | ||
"version": "1.0.0", | ||
"description": "", | ||
"main": "index.js", | ||
"private": true, | ||
"scripts": { | ||
"dev": "rspack serve", | ||
"build": "rspack build" | ||
}, | ||
"keywords": [], | ||
"author": "", | ||
"license": "MIT", | ||
"dependencies": { | ||
"@rspack/cli": "latest", | ||
"@swc/helpers": "0.5.1", | ||
"preact": "10.19.3" | ||
}, | ||
"devDependencies": { | ||
"@rspack/core": "latest", | ||
"@prefresh/babel-plugin": "0.5.1", | ||
"@prefresh/webpack": "4.0.0" | ||
}, | ||
"resolve": { | ||
"alias": { | ||
"react": "preact/compat", | ||
"react-dom/test-utils": "preact/test-utils", | ||
"react-dom": "preact/compat", | ||
"react/jsx-runtime": "preact/jsx-runtime" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
const rspack = require('@rspack/core'); | ||
const dev = process.env.NODE_ENV === 'development'; | ||
/** @type {import('@rspack/cli').Configuration} */ | ||
const config = { | ||
entry: { | ||
main: './src/index.jsx', | ||
}, | ||
resolve: { | ||
extensions: ['...', '.ts', '.tsx', '.jsx'], | ||
alias: { | ||
react: 'preact/compat', | ||
'react-dom/test-utils': 'preact/test-utils', | ||
'react-dom': 'preact/compat', // Must be below test-utils | ||
'react/jsx-runtime': 'preact/jsx-runtime', | ||
}, | ||
}, | ||
module: { | ||
rules: [ | ||
{ | ||
test: /\.jsx$/, | ||
use: { | ||
loader: 'builtin:swc-loader', | ||
options: { | ||
sourceMap: true, | ||
jsc: { | ||
parser: { | ||
syntax: 'ecmascript', | ||
jsx: true, | ||
}, | ||
externalHelpers: true, | ||
preserveAllComments: false, | ||
transform: { | ||
react: { | ||
runtime: 'automatic', | ||
pragma: 'h', | ||
pragmaFrag: 'Fragment', | ||
throwIfNamespace: true, | ||
useBuiltins: false, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
type: 'javascript/auto', | ||
}, | ||
{ | ||
test: /\.(png|svg|jpg)$/, | ||
type: 'asset/resource', | ||
}, | ||
], | ||
}, | ||
plugins: [ | ||
new rspack.HtmlRspackPlugin({ | ||
template: './index.html', | ||
}), | ||
dev && new rspack.HotModuleReplacementPlugin() | ||
].filter(Boolean), | ||
}; | ||
module.exports = config; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
.App { | ||
text-align: center; | ||
} | ||
|
||
.App-logo { | ||
height: 40vmin; | ||
pointer-events: none; | ||
} | ||
|
||
@media (prefers-reduced-motion: no-preference) { | ||
.App-logo { | ||
animation: App-logo-spin infinite 20s linear; | ||
} | ||
} | ||
|
||
.App-header { | ||
background-color: #282c34; | ||
min-height: 100vh; | ||
display: flex; | ||
flex-direction: column; | ||
align-items: center; | ||
justify-content: center; | ||
font-size: calc(10px + 2vmin); | ||
color: white; | ||
} | ||
|
||
.App-link { | ||
color: #61dafb; | ||
} | ||
|
||
@keyframes App-logo-spin { | ||
from { | ||
transform: rotate(0deg); | ||
} | ||
to { | ||
transform: rotate(360deg); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import React from 'react'; | ||
import { useState, useEffect } from 'react'; | ||
import logo from './logo.svg'; | ||
import './App.css'; | ||
|
||
function App() { | ||
const [count, setCount] = useState(1); | ||
useEffect(() => { | ||
setInterval(() => { | ||
setCount(x => x+1); | ||
},1000) | ||
},[]) | ||
return ( | ||
<div className="App"> | ||
<header className="App-header"> | ||
<img src={logo} className="App-logo" alt="logo" /> | ||
<p> | ||
Edit <code>src/App.js</code> and save to reload. | ||
</p> | ||
<div> | ||
count: {count} | ||
</div> | ||
<a | ||
className="App-link" | ||
href="https://reactjs.org" | ||
target="_blank" | ||
rel="noopener noreferrer" | ||
> | ||
Learn React | ||
</a> | ||
</header> | ||
</div> | ||
); | ||
} | ||
|
||
export default App; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
body { | ||
margin: 0; | ||
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', | ||
'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', | ||
sans-serif; | ||
-webkit-font-smoothing: antialiased; | ||
-moz-osx-font-smoothing: grayscale; | ||
} | ||
|
||
code { | ||
font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New', | ||
monospace; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import React from 'react'; | ||
import ReactDOM from 'react-dom/client'; | ||
import './index.css'; | ||
import App from './App'; | ||
|
||
const root = ReactDOM.createRoot(document.getElementById('root')); | ||
root.render( | ||
<App /> | ||
); |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.