-
Notifications
You must be signed in to change notification settings - Fork 0
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
15 changed files
with
229 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,36 @@ | ||
# Logs | ||
logs | ||
*.log | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
pnpm-debug.log* | ||
lerna-debug.log* | ||
|
||
node_modules | ||
dist | ||
dist-ssr | ||
*.local | ||
|
||
# Editor directories and files | ||
.vscode/* | ||
!.vscode/extensions.json | ||
.idea | ||
.DS_Store | ||
*.suo | ||
*.ntvs* | ||
*.njsproj | ||
*.sln | ||
*.sw? | ||
.bsp | ||
.metals | ||
.scala-build | ||
scalajs-modules | ||
scalawind.scala | ||
bun.lockb | ||
yarn.lock | ||
package-lock.json | ||
pnpm-lock.yaml | ||
target | ||
.bloop | ||
.idea |
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,3 @@ | ||
version = "3.7.15" | ||
runner.dialect = scala3 | ||
maxColumn=120 |
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,47 @@ | ||
# Scalawind Vite | ||
|
||
## Install NodeJS | ||
|
||
In case you don't have NodeJS yet, this is my recommendation: https://github.com/Schniz/fnm | ||
|
||
## Install sbt | ||
|
||
Following the instructions here: https://www.scala-sbt.org/download/ | ||
|
||
## Install dependencies | ||
|
||
```bash | ||
$ npm install | ||
# or | ||
$ bun install | ||
# or | ||
$ pnpm install | ||
# or | ||
$ yarn install | ||
``` | ||
|
||
## Start dev server | ||
|
||
```bash | ||
$ npm run dev:scala | ||
# or | ||
$ bun dev:scala | ||
# or | ||
$ pnpm dev:scala | ||
# or | ||
$ yarn dev:scala | ||
``` | ||
|
||
In another terminal: | ||
|
||
```bash | ||
$ npm run dev | ||
# or | ||
$ bun dev | ||
# or | ||
$ pnpm dev | ||
# or | ||
$ yarn dev | ||
``` | ||
|
||
Open: http://localhost:5173 |
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,17 @@ | ||
import org.scalajs.linker.interface.ModuleSplitStyle | ||
|
||
enablePlugins(ScalaJSPlugin) | ||
|
||
scalaVersion := "3.3.3" | ||
scalaJSUseMainModuleInitializer := true | ||
|
||
scalaJSLinkerConfig ~= { | ||
_.withModuleKind(ModuleKind.ESModule) | ||
.withModuleSplitStyle(ModuleSplitStyle.SmallModulesFor(List("myapp"))) | ||
} | ||
|
||
libraryDependencies += "org.scala-js" %%% "scalajs-dom" % "2.4.0" | ||
libraryDependencies += "com.github.japgolly.scalajs-react" %%% "core" % "3.0.0-beta3" | ||
|
||
Compile / fastLinkJS / scalaJSLinkerOutputDirectory := target.value / "scalajs-modules" | ||
Compile / fullLinkJS / scalaJSLinkerOutputDirectory := target.value / "scalajs-modules" |
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 @@ | ||
<!doctype html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<link rel="icon" type="image/svg+xml" href="/vite.svg" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>Scala ❤️ Tailwind</title> | ||
</head> | ||
<body> | ||
<div id="app"></div> | ||
<script type="module" src="/main.js"></script> | ||
</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,2 @@ | ||
import './style.css' | ||
import 'scalajs:main.js' |
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,25 @@ | ||
{ | ||
"name": "scalawind-vite-sbt", | ||
"private": true, | ||
"version": "0.0.0", | ||
"type": "module", | ||
"scripts": { | ||
"dev": "vite", | ||
"build": "vite build", | ||
"preview": "vite preview", | ||
"postinstall": "scalawind generate -pcr -o ./src/main/scala/myapp/scalawind.scala", | ||
"dev:scala": "sbt \"~fastLinkJS\"", | ||
"build:scala": "sbt \"fullLinkJS\"" | ||
}, | ||
"dependencies": { | ||
"react": "18.3.1", | ||
"react-dom": "18.3.1" | ||
}, | ||
"devDependencies": { | ||
"autoprefixer": "10.4.19", | ||
"postcss": "8.4.38", | ||
"scalawind": "latest", | ||
"tailwindcss": "3.4.3", | ||
"vite": "5.2.11" | ||
} | ||
} |
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,6 @@ | ||
export default { | ||
plugins: { | ||
tailwindcss: {}, | ||
autoprefixer: {}, | ||
}, | ||
} |
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 @@ | ||
sbt.version=1.10.0 |
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 @@ | ||
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.16.0") |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
28 changes: 28 additions & 0 deletions
28
examples/vite-scalajs-react-sbt/src/main/scala/myapp/index.scala
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,28 @@ | ||
package myapp | ||
|
||
import org.scalajs.dom | ||
|
||
import scalawind.* | ||
import japgolly.scalajs.react.* | ||
import japgolly.scalajs.react.vdom.html_<^.* | ||
|
||
@main | ||
def App(): Unit = | ||
val container = dom.document.getElementById("app") | ||
|
||
val Component = ScalaFnComponent | ||
.withHooks[Unit] | ||
.useState(0) | ||
.render((props, count) => { | ||
<.div( | ||
^.cls := tw.w_screen.h_screen.flex.items_center.justify_center.css, | ||
<.div( | ||
^.cls := tw.p_2.text_primary.hover(tw.bg_black.text_white).css, | ||
"Scala ❤️ Tailwind" | ||
) | ||
) | ||
}) | ||
|
||
ReactDOMClient.createRoot(container).render(Component()) | ||
|
||
end 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,3 @@ | ||
@tailwind base; | ||
@tailwind components; | ||
@tailwind utilities; |
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,33 @@ | ||
const colors = require("tailwindcss/colors"); | ||
|
||
/** @type {import('tailwindcss').Config} */ | ||
module.exports = { | ||
content: { | ||
files: ['./index.html', './target/scalajs-modules/**/*.js'], | ||
}, | ||
theme: { | ||
colors: { | ||
transparent: "transparent", | ||
current: "currentColor", | ||
black: colors.black, | ||
white: colors.white, | ||
red: colors.red, | ||
}, | ||
extend: { | ||
colors: { | ||
primary: '#DE3423', | ||
secondary: ' #380d09' | ||
}, | ||
}, | ||
}, | ||
corePlugins: [ | ||
'display', | ||
'textColor', | ||
'width', | ||
'height', | ||
'alignItems', | ||
'justifyContent', | ||
'padding', | ||
'backgroundColor' | ||
] | ||
}; |
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 @@ | ||
import { defineConfig } from 'vite'; | ||
export default defineConfig({ | ||
plugins: [ | ||
], | ||
resolve: { | ||
alias: [ | ||
{ | ||
find: /^scalajs:(.*)$/, | ||
replacement: `/target/scalajs-modules/$1` | ||
} | ||
] | ||
}, | ||
}); |