├── .gitignore
├── .npmignore
├── index.js
├── generator
├── templates
│ ├── .eslintrc.js
│ ├── postcss.config.js
│ ├── src
│ │ └── assets
│ │ │ └── styles
│ │ │ └── tailwind.postcss
│ └── tailwind.config.js
└── index.js
├── .editorconfig
├── package.json
└── README.md
/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules*
2 |
--------------------------------------------------------------------------------
/.npmignore:
--------------------------------------------------------------------------------
1 | node_modules*
2 | .*
3 |
--------------------------------------------------------------------------------
/index.js:
--------------------------------------------------------------------------------
1 | module.exports = () => {}
2 |
--------------------------------------------------------------------------------
/generator/templates/.eslintrc.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | rules: {
3 | 'indent': [ 'error', 2 ],
4 | },
5 | }
6 |
--------------------------------------------------------------------------------
/.editorconfig:
--------------------------------------------------------------------------------
1 | root = true
2 |
3 | [*]
4 | charset = utf-8
5 | end_of_line = lf
6 | indent_size = 2
7 | indent_style = tab
8 | insert_final_newline = true
9 | trim_trailing_whitespace = true
10 |
11 | [**/templates/**]
12 | indent_style = space
13 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "@ky-is/vue-cli-plugin-tailwind",
3 | "version": "2.0.0",
4 | "description": "Write utility-first CSS with future standards in your Vue app using TailwindCSS.",
5 | "author": "Kyle Coburn",
6 | "license": "ISC",
7 | "repository": {
8 | "type": "git",
9 | "url": "git+https://github.com/ky-is/vue-cli-plugin-tailwind.git"
10 | },
11 | "bugs": {
12 | "url": "https://github.com/ky-is/vue-cli-plugin-tailwind/issues"
13 | },
14 | "homepage": "https://github.com/ky-is/vue-cli-plugin-tailwind#readme",
15 | "devDependencies": {
16 | "@ky-is/eslint-config": "^1.7.0",
17 | "eslint": "^5.16.0"
18 | },
19 | "eslintConfig": {
20 | "extends": "@ky-is"
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/generator/templates/postcss.config.js:
--------------------------------------------------------------------------------
1 | const IN_PRODUCTION = process.env.NODE_ENV === 'production'
2 |
3 | module.exports = {
4 | plugins: [
5 | require('postcss-preset-env')({ stage: 0 }),
6 | require('tailwindcss')(),
7 | IN_PRODUCTION && require('@fullhuman/postcss-purgecss')({
8 | content: [ `./public/**/*.html`, `./src/**/*.vue` ],
9 | defaultExtractor (content) {
10 | const contentWithoutStyleBlocks = content.replace(/\n`
42 | }
43 | files[appFileName] = lines.join('\n')
44 | })
45 | }
46 |
--------------------------------------------------------------------------------
/generator/templates/tailwind.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | theme: {
3 | extend: {
4 | inset: {
5 | 'full': '100%',
6 | },
7 | opacity: {
8 | '10': '0.1',
9 | '90': '0.9',
10 | },
11 | },
12 | },
13 | variants: {
14 | appearance: ['responsive'],
15 | backgroundAttachment: ['responsive'],
16 | backgroundColor: ['responsive', 'hover', 'focus'],
17 | backgroundPosition: ['responsive'],
18 | backgroundRepeat: ['responsive'],
19 | backgroundSize: ['responsive'],
20 | borderCollapse: [],
21 | borderColor: ['responsive', 'hover', 'focus'],
22 | borderRadius: ['responsive'],
23 | borderStyle: ['responsive'],
24 | borderWidth: ['responsive'],
25 | cursor: ['responsive'],
26 | display: ['responsive', 'group-hover'],
27 | flexDirection: ['responsive'],
28 | flexWrap: ['responsive'],
29 | alignItems: ['responsive'],
30 | alignSelf: ['responsive'],
31 | justifyContent: ['responsive'],
32 | alignContent: ['responsive'],
33 | flex: ['responsive'],
34 | flexGrow: ['responsive'],
35 | flexShrink: ['responsive'],
36 | float: ['responsive'],
37 | fontFamily: ['responsive'],
38 | fontWeight: ['responsive', 'hover', 'focus'],
39 | height: ['responsive'],
40 | lineHeight: ['responsive'],
41 | listStylePosition: ['responsive'],
42 | listStyleType: ['responsive'],
43 | margin: ['responsive'],
44 | maxHeight: ['responsive'],
45 | maxWidth: ['responsive'],
46 | minHeight: ['responsive'],
47 | minWidth: ['responsive'],
48 | negativeMargin: ['responsive'],
49 | objectFit: ['responsive'],
50 | objectPosition: ['responsive'],
51 | opacity: ['responsive'],
52 | outline: ['focus'],
53 | overflow: ['responsive'],
54 | padding: ['responsive'],
55 | pointerEvents: ['responsive'],
56 | position: ['responsive'],
57 | inset: ['responsive'],
58 | resize: ['responsive'],
59 | boxShadow: ['responsive', 'hover', 'focus'],
60 | fill: [],
61 | stroke: [],
62 | tableLayout: ['responsive'],
63 | textAlign: ['responsive'],
64 | textColor: ['responsive', 'hover', 'focus'],
65 | fontSize: ['responsive'],
66 | fontStyle: ['responsive'],
67 | textTransform: ['responsive'],
68 | textDecoration: ['responsive', 'hover', 'focus'],
69 | fontSmoothing: ['responsive'],
70 | letterSpacing: ['responsive'],
71 | userSelect: ['responsive'],
72 | verticalAlign: ['responsive'],
73 | visibility: ['responsive', 'hover', 'group-hover'],
74 | whitespace: ['responsive'],
75 | wordBreak: ['responsive'],
76 | width: ['responsive'],
77 | zIndex: ['responsive'],
78 | },
79 | corePlugins: {
80 | container: false,
81 | },
82 | plugins: [],
83 | }
84 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # vue-cli-plugin-tailwind
2 |
3 | [Tailwind CSS](https://tailwindcss.com/docs/what-is-tailwind)'s utility classes are minned by [Purgecss](https://www.purgecss.com), saving hundreds of kBs in production builds. [postcss-preset-env](https://preset-env.cssdb.org/features) polyfills modern CSS standards based on your `browserslist` configuration.
4 |
5 |
6 | ## Install
7 |
8 | ### TailwindCSS v1.0
9 |
10 | ```console
11 | vue add @ky-is/tailwind
12 | ```
13 |
14 | When the plugin is updated, you can upgrade your configuration with:
15 | ```console
16 | vue invoke @ky-is/tailwind
17 | ```
18 |
19 | ### TailwindCSS v0.x
20 |
21 | See the [`tailwind-0.x` branch](https://github.com/ky-is/vue-cli-plugin-tailwind/tree/tailwind-0.x).
22 |
23 |
24 | ## Usage
25 |
26 | Use inline classes, or `@apply`. For example, in `src/components/HelloWorld.vue` of the auto-generated cli app:
27 | ```html
28 |
33 | ```
34 |
35 | Applies scoped, browser-prefixed CSS, while PurgeCSS strips all other unused classes, including the thousands generated by Tailwind.
36 |
37 |
38 | ## Configuration
39 |
40 | ### `postcss.config.js` Plugins
41 |
42 | - `postcss-preset-env`: Defaults to stage 2, as these draft proposals are considered reasonably stable. If you want to enable handy experimental features like nested classes (`a { &:hover: {...} }`), change to `stage: 0`. You can safely delete this plugin from the list if you only write old CSS or use another preprocessor.
43 |
44 | - `@fullhuman/postcss-purgecss`: Purgecss removes all CSS classes that it can't find reference to. By default, all Vue and style files in the `src` folder are included. Adjust `content` array if you have CSS classes in other files. Add class names to the `whitelist` array you want to manually prevent PurgeCSS from removing if it thinks they're unused.
45 |
46 | ### Whitelisting
47 |
48 | Any CSS class that isn't used inside your `.html` files in `public/`, or by your `.vue` components (outside of the `