|
2 | 2 | [](https://tailwindcss.com/) |
3 | 3 | [](https://github.com/forsartis/vue-cli-plugin-tailwind/blob/master/LICENSE) |
4 | 4 |
|
| 5 | +A plugin that adds Tailwind CSS and Purgecss to your vue-cli project. |
5 | 6 |
|
6 | 7 | ## Getting started |
7 | | - |
8 | 8 | Inside your vue-cli project folder add the plugin via: |
9 | 9 | ``` |
10 | 10 | vue add tailwind |
11 | 11 | ``` |
| 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. |
12 | 16 |
|
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. |
14 | 18 |
|
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 | +} |
16 | 50 |
|
| 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 |
17 | 77 | [MIT](https://github.com/forsartis/vue-cli-plugin-tailwind/blob/master/LICENSE) |
0 commit comments