Skip to content
This repository was archived by the owner on Apr 19, 2021. It is now read-only.

Commit 35d43ac

Browse files
committed
⚡️ feat: support for Tailwind CSS IntelliSense
1 parent f3ef71e commit 35d43ac

File tree

6 files changed

+53
-54
lines changed

6 files changed

+53
-54
lines changed

.vscode/extensions.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"recommendations": [
3+
"bradlc.vscode-tailwindcss",
34
"dbaeumer.vscode-eslint",
45
"jsayol.firebase-explorer",
56
"svelte.svelte-vscode"

README.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ The site that builds from this repository can be found [here](https://fir-sapper
55

66
This is an extremely opinionated Sapper project base intended for my own use. That being said, there is quite a bit of work put into it to make it generalized and adaptable to your own setup, given that you want to use *most* of these things. The lower something is on this list, the easier it is to reconfigure or remove:
77
- [Sapper for Svelte](https://sapper.svelte.dev/)
8-
- [Official VS Code Plugin](https://marketplace.visualstudio.com/items?itemName=svelte.svelte-vscode)
8+
- [Official VS Code Extension](https://marketplace.visualstudio.com/items?itemName=svelte.svelte-vscode)
99
- [Firebase](https://firebase.google.com/)
1010
- [Functions](https://firebase.google.com/docs/functions/) for Server Side Rendering (SSR)
1111
- [Hosting](https://firebase.google.com/docs/hosting) for static assets
@@ -16,6 +16,7 @@ This is an extremely opinionated Sapper project base intended for my own use. Th
1616
- Inside Svelte components, thanks to [`svelte-preprocess`](https://github.com/kaisermann/svelte-preprocess)
1717
- [PostCSS](https://postcss.org/)
1818
- [Tailwind CSS](https://tailwindcss.com/)
19+
- [Official VS Code Extension](https://marketplace.visualstudio.com/items?itemName=bradlc.vscode-tailwindcss)
1920
- [postcss-import](https://github.com/postcss/postcss-import)
2021
- [PurgeCSS](https://www.purgecss.com/)
2122
- [CSSNano](https://cssnano.co/)
@@ -26,7 +27,7 @@ This is an extremely opinionated Sapper project base intended for my own use. Th
2627
- [`manifest.json`](https://developer.mozilla.org/en-US/docs/Web/Manifest)'s most important fields filled out
2728
- High [Lighthouse](https://developers.google.com/web/tools/lighthouse) audit score
2829
- [ESLint](https://eslint.org/)
29-
- [VS Code Plugin](https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint)
30+
- [VS Code Extension](https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint)
3031
- `eslint:fix` package script
3132

3233
This template comes from combining two of my smaller ones: [one for Tailwind CSS (PostCSS)](https://github.com/babichjacob/sapper-postcss-template), and [another for TypeScript and GraphQL](https://github.com/babichjacob/sapper-typescript-graphql-template). If this is too much for you, check out one of those!
@@ -120,10 +121,10 @@ This project base comes with [source maps](https://blog.teamtreehouse.com/introd
120121
1. Remove all Tailwind imports in the `src/global.pcss` file
121122
2. Remove these lines in `postcss.config.js`:
122123
1. ```js
123-
import tailwindcss from "tailwindcss";
124+
const tailwindcss = require("tailwindcss");
124125
```
125126
3. ```js
126-
import * as tailwindcssConfig from "./tailwind.config";
127+
const tailwindcssConfig = require("./tailwind.config");
127128
```
128129
3. ```js
129130
tailwindcss(tailwindcssConfig),

postcss.config.js

Lines changed: 28 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,36 @@
1-
import cssnano from "cssnano";
2-
import postcssImport from "postcss-import";
3-
import postcssPresetEnv from "postcss-preset-env";
4-
import postcssPurgecss from "@fullhuman/postcss-purgecss";
5-
import tailwindcss from "tailwindcss";
6-
import * as tailwindcssConfig from "./tailwind.config";
1+
const cssnano = require("cssnano");
2+
const postcssImport = require("postcss-import");
3+
const postcssPresetEnv = require("postcss-preset-env");
4+
const postcssPurgecss = require("@fullhuman/postcss-purgecss");
5+
const tailwindcss = require("tailwindcss");
6+
const tailwindcssConfig = require("./tailwind.config");
77

88
const mode = process.env.NODE_ENV;
99
const dev = mode === "development";
1010

11-
export const plugins = [
12-
postcssImport,
11+
module.exports = {
12+
plugins: [
13+
postcssImport,
1314

14-
tailwindcss(tailwindcssConfig),
15+
tailwindcss(tailwindcssConfig),
1516

16-
postcssPresetEnv({
17-
features: {
18-
// https://github.com/tailwindcss/tailwindcss/issues/1190
19-
"focus-within-pseudo-class": false,
20-
},
21-
}),
17+
postcssPresetEnv({
18+
features: {
19+
// https://github.com/tailwindcss/tailwindcss/issues/1190
20+
"focus-within-pseudo-class": false,
21+
},
22+
}),
2223

23-
!dev && postcssPurgecss({
24-
content: ["./src/**/*.svelte", "./src/**/*.html"],
25-
defaultExtractor: (content) => [...content.matchAll(/(?:class:)*([\w\d-/:%.]+)/gm)].map(([_match, group, ..._rest]) => group),
26-
}),
24+
!dev && postcssPurgecss({
25+
content: ["./src/**/*.svelte", "./src/**/*.html"],
26+
defaultExtractor: (content) => [...content.matchAll(/(?:class:)*([\w\d-/:%.]+)/gm)].map(([_match, group, ..._rest]) => group),
27+
}),
2728

28-
!dev && cssnano({
29-
preset: [
30-
"default",
31-
{ discardComments: { removeAll: true } },
32-
],
33-
}),
34-
].filter(Boolean);
29+
!dev && cssnano({
30+
preset: [
31+
"default",
32+
{ discardComments: { removeAll: true } },
33+
],
34+
}),
35+
].filter(Boolean),
36+
};

rollup.config.js

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,9 @@ import svelte from "rollup-plugin-svelte";
77
import babel from "@rollup/plugin-babel";
88
import { terser } from "rollup-plugin-terser";
99
import config from "sapper/config/rollup";
10-
import sveltePreprocess from "svelte-preprocess";
1110
import pkg from "./package.json";
12-
import * as postcss from "./postcss.config";
1311

14-
const { defaults } = require("./svelte.config.js");
15-
16-
const preprocess = [
17-
sveltePreprocess({ defaults, postcss }),
18-
// You could have more preprocessors, like MDsveX
19-
];
12+
const { preprocess } = require("./svelte.config.js");
2013

2114
const mode = process.env.NODE_ENV;
2215
const dev = mode === "development";

svelte.config.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
const sveltePreprocess = require("svelte-preprocess");
2+
const postcss = require("./postcss.config");
23

34
const defaults = {
45
script: "typescript",
56
style: "postcss",
67
};
78

89
module.exports = {
9-
// Real svelte-preprocess configuration is in `rollup.config.js`
10-
// This is only for the language server for VS Code and svelte-check
11-
preprocess: sveltePreprocess({ defaults }),
12-
defaults,
10+
preprocess: [
11+
sveltePreprocess({ defaults, postcss }),
12+
// You could have more preprocessors, like mdsvex
13+
],
1314
};

tailwind.config.js

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,19 @@
55
View the full documentation at https://tailwindcss.com.
66
*/
77

8-
import tailwindui from "@tailwindcss/ui";
8+
const tailwindui = require("@tailwindcss/ui");
99

10-
export const purge = false; // Purging is taken care of in postcss.config.js
10+
module.exports = {
11+
purge: false, // Purging is taken care of in postcss.config.js
12+
theme: {
13+
extend: {},
14+
},
15+
variants: {},
16+
plugins: [
17+
tailwindui,
18+
],
1119

12-
export const theme = {
13-
extend: {},
14-
};
15-
export const variants = {};
16-
export const plugins = [
17-
tailwindui, // Can drastically slow down build time, disable if a problem
18-
];
19-
20-
export const future = {
21-
removeDeprecatedGapUtilities: true,
20+
future: {
21+
removeDeprecatedGapUtilities: true,
22+
},
2223
};

0 commit comments

Comments
 (0)