Skip to content

Commit 4d2892d

Browse files
committed
update README
1 parent 0fdc232 commit 4d2892d

File tree

3 files changed

+67
-7
lines changed

3 files changed

+67
-7
lines changed

README.md

Lines changed: 63 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,76 @@
22
[![Tailwind CSS](https://img.shields.io/npm/dependency-version/vue-cli-plugin-tailwind/tailwindcss.svg)](https://tailwindcss.com/)
33
[![License](https://img.shields.io/npm/l/vue-cli-plugin-tailwind.svg)](https://github.com/forsartis/vue-cli-plugin-tailwind/blob/master/LICENSE)
44

5+
A plugin that adds Tailwind CSS and Purgecss to your vue-cli project.
56

67
## Getting started
7-
88
Inside your vue-cli project folder add the plugin via:
99
```
1010
vue add tailwind
1111
```
12+
Choose what Tailwind config you want to generate:
13+
* **none** - Won't create a config file. Useful if you already have a config or you don't need to change Tailwinds default styles.
14+
* **minimal** *(default)* - Will create a minimal `tailwind.config.js` file where you can define your customizations.
15+
* **full** - Will generate a `tailwind.config.js` file containing the entire default configuration.
1216

13-
:warning: Check the plugins order in your PostCSS config (autoprefixer should run after tailwindcss).
17+
See [Tailwinds configuration guide](https://next.tailwindcss.com/docs/configuration) for more info.
1418

15-
## License
19+
## PostCSS Configuration
20+
Tailwind CSS and Purgecss will be added as plugins in your PostCSS config.
21+
```javascript
22+
// postcss.config.js
23+
module.exports = {
24+
plugins: {
25+
tailwindcss: {},
26+
'vue-cli-plugin-tailwind/purgecss': {},
27+
autoprefixer: {},
28+
},
29+
};
30+
```
31+
### Custom Tailwind config file name
32+
If you use a name other than `tailwind.config.js` for the Tailwind config file, you will need to specify it in your PostCSS configuration.
33+
```javascript
34+
// postcss.config.js
35+
module.exports = {
36+
plugins: {
37+
tailwindcss: 'custom-name.js',
38+
//...
39+
},
40+
};
41+
```
42+
### Configure Purgecss
43+
By default Purgecss will look for css selectors in your `.html` files inside the `./public` directory and `.vue` files inside the `./src` directory.
44+
```javascript
45+
class TailwindExtractor {
46+
static extract(content) {
47+
return content.match(/[A-Za-z0-9-_:\/]+/g) || [];
48+
}
49+
}
1650

51+
let config = {
52+
content: ['./public/**/*.html', './src/**/*.vue'],
53+
extractors: [
54+
{
55+
extractor: TailwindExtractor,
56+
extensions: ['html', 'vue'],
57+
},
58+
],
59+
};
60+
```
61+
You can extend/override the default config in your PostCSS configuration.
62+
```javascript
63+
// postcss.config.js
64+
module.exports = {
65+
plugins: {
66+
tailwindcss: {},
67+
'vue-cli-plugin-tailwind/purgecss': {
68+
whitelist: ['foo', 'bar'],
69+
},
70+
autoprefixer: {},
71+
},
72+
};
73+
```
74+
Check [https://www.purgecss.com/configuration#options](https://www.purgecss.com/configuration#options) for a list of available options.
75+
76+
## License
1777
[MIT](https://github.com/forsartis/vue-cli-plugin-tailwind/blob/master/LICENSE)

generator/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ module.exports = (api, options) => {
5555
api.injectImports(api.entryFile, `import './assets/tailwind.css'`);
5656
api.render('./template');
5757

58-
if (options.overwriteConfig) {
58+
if (options.replaceConfig) {
5959
const filename = 'tailwind.config.js';
6060
delete api.generator.files[filename];
6161
const configPath = path.join(api.generator.context, filename);
@@ -66,7 +66,7 @@ module.exports = (api, options) => {
6666
}
6767
}
6868

69-
if (options.initConfig && options.overwriteConfig !== false) {
69+
if (options.initConfig && options.replaceConfig !== false) {
7070
api.onCreateComplete(() => {
7171
generateConfig(options.initConfig);
7272
});

prompts.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ module.exports = [
1313
default: 1,
1414
},
1515
{
16-
name: 'overwriteConfig',
16+
name: 'replaceConfig',
1717
type: 'confirm',
18-
message: 'tailwind.config.js already exists! Do you want to overwrite?',
18+
message: 'tailwind.config.js already exists! Do you want to replace it?',
1919
default: false,
2020
when: answers => {
2121
return answers.initConfig && fs.existsSync('./tailwind.config.js');

0 commit comments

Comments
 (0)