npx svelte-add tailwindcss

This commit is contained in:
Ryan Gossiaux
2021-12-13 21:05:36 -08:00
parent 53adc38513
commit 263cbd0483
6 changed files with 53 additions and 3 deletions

View File

@@ -23,9 +23,14 @@
"prettier-plugin-svelte": "^2.4.0", "prettier-plugin-svelte": "^2.4.0",
"svelte": "^3.44.0", "svelte": "^3.44.0",
"svelte-check": "^2.2.6", "svelte-check": "^2.2.6",
"svelte-preprocess": "^4.9.4", "svelte-preprocess": "^4.9.8",
"tslib": "^2.3.1", "tslib": "^2.3.1",
"typescript": "^4.4.3" "typescript": "^4.4.3",
"postcss": "^8.3.9",
"postcss-load-config": "^3.1.0",
"autoprefixer": "^10.3.7",
"cssnano": "^5.0.8",
"tailwindcss": "^3.0.0"
}, },
"type": "module" "type": "module"
} }

21
postcss.config.cjs Normal file
View File

@@ -0,0 +1,21 @@
const tailwindcss = require("tailwindcss");
const autoprefixer = require("autoprefixer");
const cssnano = require("cssnano");
const mode = process.env.NODE_ENV;
const dev = mode === "development";
const config = {
plugins: [
//Some plugins, like tailwindcss/nesting, need to run before Tailwind,
tailwindcss(),
//But others, like autoprefixer, need to run after,
autoprefixer(),
!dev &&
cssnano({
preset: "default",
}),
],
};
module.exports = config;

4
src/app.css Normal file
View File

@@ -0,0 +1,4 @@
/* Write your global styles here, in PostCSS syntax */
@tailwind base;
@tailwind components;
@tailwind utilities;

View File

@@ -0,0 +1,5 @@
<script>
import "../app.css";
</script>
<slot />

View File

@@ -5,7 +5,11 @@ import preprocess from "svelte-preprocess";
const config = { const config = {
// Consult https://github.com/sveltejs/svelte-preprocess // Consult https://github.com/sveltejs/svelte-preprocess
// for more information about preprocessors // for more information about preprocessors
preprocess: preprocess(), preprocess: [
preprocess({
postcss: true,
}),
],
kit: { kit: {
adapter: adapter(), adapter: adapter(),

11
tailwind.config.cjs Normal file
View File

@@ -0,0 +1,11 @@
const config = {
content: ["./src/**/*.{html,js,svelte,ts}"],
theme: {
extend: {},
},
plugins: [],
};
module.exports = config;