(chore) Add support for .scss and tailwindcss

This commit is contained in:
KingRainbow44
2023-11-27 12:14:22 -05:00
parent b9015d140c
commit 91cb38c837
9 changed files with 94 additions and 23 deletions

13
.editorconfig Normal file
View File

@@ -0,0 +1,13 @@
root = true
[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
max_line_length = 120
indent_size = 4
indent_style = space
[*.json]
indent_size = 2

25
cfg/postcss.config.ts Normal file
View File

@@ -0,0 +1,25 @@
import tailwind from "tailwindcss";
import autoprefixer from "autoprefixer";
import cssnanoPlugin from "cssnano";
import tailwindConfig from "./tailwind.config";
const mode = process.env.NODE_ENV;
const dev = mode === "development";
export default {
plugins: (() => {
let plugins = [
// Some plugins, like TailwindCSS/Nesting, need to run before Tailwind.
tailwind(tailwindConfig),
// But others, like autoprefixer, need to run after.
autoprefixer()
];
!dev && cssnanoPlugin({
preset: "default"
});
return plugins;
})()
};

11
cfg/tailwind.config.ts Normal file
View File

@@ -0,0 +1,11 @@
import { Config } from "tailwindcss";
export default {
content: ["./src/**/*.{html,js,tsx,ts}"],
mode: "jit",
theme: {
extend: {}
},
darkMode: "class",
plugins: []
} as Config;

View File

@@ -1,7 +1,7 @@
{ {
"name": "cultivation", "name": "cultivation",
"private": true, "private": true,
"version": "0.0.0", "version": "2.0.0",
"type": "module", "type": "module",
"scripts": { "scripts": {
"dev": "vite", "dev": "vite",
@@ -10,13 +10,24 @@
"tauri": "tauri" "tauri": "tauri"
}, },
"dependencies": { "dependencies": {
"@tauri-apps/api": "^1.5.1",
"preact": "^10.16.0", "preact": "^10.16.0",
"@tauri-apps/api": "^1.5.1" "react-icons": "^4.12.0",
"zustand": "^4.4.6"
}, },
"devDependencies": { "devDependencies": {
"@preact/preset-vite": "^2.5.0", "@preact/preset-vite": "^2.5.0",
"@tauri-apps/cli": "^1.5.6",
"@types/node": "^20.10.0",
"autoprefixer": "^10.4.16",
"cssnano": "^6.0.1",
"postcss": "^8.4.31",
"postcss-load-config": "^4.0.2",
"prettier": "^3.1.0",
"sass": "^1.69.5",
"tailwindcss": "^3.3.5",
"typescript": "^5.0.2", "typescript": "^5.0.2",
"vite": "^4.4.4", "vite": "^4.4.4",
"@tauri-apps/cli": "^1.5.6" "vite-tsconfig-paths": "^4.2.1"
} }
} }

2
src-tauri/Cargo.lock generated
View File

@@ -501,7 +501,7 @@ dependencies = [
[[package]] [[package]]
name = "cultivation" name = "cultivation"
version = "0.0.0" version = "2.0.0"
dependencies = [ dependencies = [
"serde", "serde",
"serde_json", "serde_json",

View File

@@ -1,10 +1,10 @@
[package] [package]
name = "cultivation" name = "cultivation"
version = "0.0.0" version = "2.0.0"
description = "A Tauri App" description = "Anime game launcher"
authors = ["you"] authors = ["KingRainbow44", "SpikeHD"]
license = "" license = "MIT"
repository = "" repository = "https://github.com/Grasscutters/Cultivation"
edition = "2021" edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

View File

@@ -36,9 +36,9 @@
{ {
"fullscreen": false, "fullscreen": false,
"resizable": true, "resizable": true,
"title": "cultivation", "title": "Cultivation",
"width": 800, "width": 1280,
"height": 600 "height": 730
} }
] ]
} }

View File

@@ -6,5 +6,9 @@
"moduleResolution": "bundler", "moduleResolution": "bundler",
"allowSyntheticDefaultImports": true "allowSyntheticDefaultImports": true
}, },
"include": ["vite.config.ts"] "include": [
"vite.config.ts",
"cfg/postcss.config.ts",
"cfg/tailwind.config.ts",
]
} }

View File

@@ -1,17 +1,24 @@
import { defineConfig } from "vite"; import { defineConfig } from "vite";
import preact from "@preact/preset-vite"; import preact from "@preact/preset-vite";
import tsconfigPaths from "vite-tsconfig-paths";
import postcss from "./cfg/postcss.config";
// https://vitejs.dev/config/ // https://vitejs.dev/config/
export default defineConfig(async () => ({ export default defineConfig(async () => ({
plugins: [preact()], plugins: [
preact(),
tsconfigPaths()
],
// Vite options tailored for Tauri development and only applied in `tauri dev` or `tauri build` css: { postcss },
//
// 1. prevent vite from obscuring rust errors // Vite options tailored for Tauri development and only applied in `tauri dev` or `tauri build`
clearScreen: false, //
// 2. tauri expects a fixed port, fail if that port is not available // 1. prevent vite from obscuring rust errors
server: { clearScreen: false,
port: 1420, // 2. tauri expects a fixed port, fail if that port is not available
strictPort: true, server: {
} port: 1420,
strictPort: true,
}
})); }));