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

Commit 7f4d826

Browse files
committed
⚡️ feat: support for Tailwind CSS IntelliSense
1 parent 84016dc commit 7f4d826

7 files changed

+54
-55
lines changed

.vscode/extensions.json

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"recommendations": [
3+
"bradlc.vscode-tailwindcss",
34
"svelte.svelte-vscode"
45
]
56
}

README.md

+5-4
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@ This is an extension to the [official Sapper Rollup template](https://github.com
77
If you're looking for something with much, much more bundled in, check out [my opinionated project base](https://github.com/babichjacob/sapper-firebase-typescript-graphql-tailwindcss-actions-template).
88

99
- [Sapper for Svelte](https://sapper.svelte.dev/)
10-
- [Official VS Code Plugin](https://marketplace.visualstudio.com/items?itemName=svelte.svelte-vscode)
10+
- [Official VS Code Extension](https://marketplace.visualstudio.com/items?itemName=svelte.svelte-vscode)
1111
- [PostCSS](https://postcss.org/)
1212
- [Tailwind CSS](https://tailwindcss.com/)
13+
- [Official VS Code Extension](https://marketplace.visualstudio.com/items?itemName=bradlc.vscode-tailwindcss)
1314
- [postcss-import](https://github.com/postcss/postcss-import)
1415
- [PurgeCSS](https://www.purgecss.com/)
1516
- [CSSNano](https://cssnano.co/)
@@ -18,7 +19,7 @@ If you're looking for something with much, much more bundled in, check out [my o
1819
- [`manifest.json`](https://developer.mozilla.org/en-US/docs/Web/Manifest)'s most important fields filled out
1920
- High [Lighthouse](https://developers.google.com/web/tools/lighthouse) audit score
2021
- [ESLint](https://eslint.org/)
21-
- [VS Code Plugin](https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint)
22+
- [VS Code Extension](https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint)
2223
- `eslint:fix` package script
2324

2425
## 📋 Copy
@@ -71,10 +72,10 @@ npm run export
7172
1. Remove all Tailwind imports in the `src/global.pcss` file
7273
2. Remove these lines in `postcss.config.js`:
7374
1. ```js
74-
import tailwindcss from "tailwindcss";
75+
const tailwindcss = require("tailwindcss");
7576
```
7677
3. ```js
77-
import * as tailwindcssConfig from "./tailwind.config";
78+
const tailwindcssConfig = require("./tailwind.config");
7879
```
7980
3. ```js
8081
tailwindcss(tailwindcssConfig),

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"url": "https://github.com/babichjacob/sapper-postcss-template.git"
1717
},
1818
"license": "MIT",
19-
"version": "2020.08.20",
19+
"version": "2020.08.27",
2020
"scripts": {
2121
"eslint": "eslint",
2222
"eslint:fix": "eslint --fix ./*.js ./src/*.js ./src/routes/**/*.svelte ./src/components/**/*.svelte",

postcss.config.js

+28-26
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

+1-8
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,9 @@ import svelte from "rollup-plugin-svelte";
55
import babel from "@rollup/plugin-babel";
66
import { terser } from "rollup-plugin-terser";
77
import config from "sapper/config/rollup";
8-
import sveltePreprocess from "svelte-preprocess";
98
import pkg from "./package.json";
10-
import * as postcss from "./postcss.config";
119

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

1912
const mode = process.env.NODE_ENV;
2013
const dev = mode === "development";

svelte.config.js

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
const sveltePreprocess = require("svelte-preprocess");
2+
const postcss = require("./postcss.config");
23

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

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

tailwind.config.js

+13-12
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)