vue-cli-plugin-tailwind
Advanced tools
Comparing version 0.4.2 to 1.0.0-beta.1
@@ -31,2 +31,11 @@ const fs = require('fs'); | ||
function generateConfig(option) { | ||
const args = ['init']; | ||
if (option === 'full') { | ||
args.push('--full'); | ||
} | ||
const { spawnSync } = require('child_process'); | ||
spawnSync('./node_modules/.bin/tailwind', args); | ||
} | ||
module.exports = (api, options) => { | ||
@@ -37,3 +46,3 @@ const postcss = readPostcssConfig(api.generator); | ||
plugins: { | ||
tailwindcss: './tailwind.config.js', | ||
tailwindcss: {}, | ||
'vue-cli-plugin-tailwind/purgecss': {}, | ||
@@ -51,6 +60,18 @@ }, | ||
api.onCreateComplete(() => { | ||
const { spawnSync } = require('child_process'); | ||
spawnSync('./node_modules/.bin/tailwind', ['init', 'tailwind.config.js']); | ||
}); | ||
if (options.replaceConfig) { | ||
const filename = 'tailwind.config.js'; | ||
delete api.generator.files[filename]; | ||
const configPath = path.join(api.generator.context, filename); | ||
try { | ||
fs.unlinkSync(configPath); | ||
} catch (error) { | ||
throw new Error(error); | ||
} | ||
} | ||
if (options.initConfig && options.replaceConfig !== false) { | ||
api.onCreateComplete(() => { | ||
generateConfig(options.initConfig); | ||
}); | ||
} | ||
}; |
{ | ||
"name": "vue-cli-plugin-tailwind", | ||
"version": "0.4.2", | ||
"version": "1.0.0-beta.1", | ||
"description": "vue-cli plugin for Tailwind CSS", | ||
@@ -22,7 +22,4 @@ "author": "Jens Eggerstedt <j.eggerstedt@kaibatech.de>", | ||
"@fullhuman/postcss-purgecss": "^1.1.0", | ||
"tailwindcss": "^0.7.4" | ||
}, | ||
"peerDependencies": { | ||
"@vue/cli-shared-utils": "^3.0.0" | ||
"tailwindcss": "^1.0.0-beta.3" | ||
} | ||
} |
@@ -11,3 +11,3 @@ const isHotReloaded = process.argv.includes('serve'); | ||
let config = { | ||
content: ['./public/index.html', './src/**/*.vue'], | ||
content: ['./public/**/*.html', './src/**/*.vue'], | ||
extractors: [ | ||
@@ -14,0 +14,0 @@ { |
@@ -5,5 +5,5 @@ # vue-cli-plugin-tailwind | ||
A plugin that adds Tailwind CSS and Purgecss to your vue-cli project. | ||
## Getting started | ||
Inside your vue-cli project folder add the plugin via: | ||
@@ -13,7 +13,67 @@ ``` | ||
``` | ||
Choose what Tailwind config you want to generate: | ||
* **none** - Won't create a config file. Useful if you already have a config or you don't need to change Tailwinds default styles. | ||
* **minimal** *(default)* - Will create a minimal `tailwind.config.js` file where you can define your customizations. | ||
* **full** - Will generate a `tailwind.config.js` file containing the entire default configuration. | ||
:warning: Check the plugins order in your PostCSS config (autoprefixer should run after tailwindcss). | ||
See [Tailwinds configuration guide](https://next.tailwindcss.com/docs/configuration) for more info. | ||
## PostCSS Configuration | ||
Tailwind CSS and Purgecss will be added as plugins in your PostCSS config. | ||
```javascript | ||
// postcss.config.js | ||
module.exports = { | ||
plugins: { | ||
tailwindcss: {}, | ||
'vue-cli-plugin-tailwind/purgecss': {}, | ||
autoprefixer: {}, | ||
}, | ||
}; | ||
``` | ||
### Custom Tailwind config file name | ||
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. | ||
```javascript | ||
// postcss.config.js | ||
module.exports = { | ||
plugins: { | ||
tailwindcss: 'custom-name.js', | ||
//... | ||
}, | ||
}; | ||
``` | ||
### Configure Purgecss | ||
By default Purgecss will look for css selectors in your `.html` files inside the `./public` directory and `.vue` files inside the `./src` directory. | ||
```javascript | ||
class TailwindExtractor { | ||
static extract(content) { | ||
return content.match(/[A-Za-z0-9-_:\/]+/g) || []; | ||
} | ||
} | ||
let config = { | ||
content: ['./public/**/*.html', './src/**/*.vue'], | ||
extractors: [ | ||
{ | ||
extractor: TailwindExtractor, | ||
extensions: ['html', 'vue'], | ||
}, | ||
], | ||
}; | ||
``` | ||
You can extend/override the default config in your PostCSS configuration. | ||
```javascript | ||
// postcss.config.js | ||
module.exports = { | ||
plugins: { | ||
tailwindcss: {}, | ||
'vue-cli-plugin-tailwind/purgecss': { | ||
whitelist: ['foo', 'bar'], | ||
}, | ||
autoprefixer: {}, | ||
}, | ||
}; | ||
``` | ||
Check [https://www.purgecss.com/configuration#options](https://www.purgecss.com/configuration#options) for a list of available options. | ||
## License | ||
[MIT](https://github.com/forsartis/vue-cli-plugin-tailwind/blob/master/LICENSE) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
9286
2
9
110
78
2
+ Added@fullhuman/postcss-purgecss@2.3.0(transitive)
+ Addedacorn@7.4.1(transitive)
+ Addedacorn-node@1.8.2(transitive)
+ Addedacorn-walk@7.2.0(transitive)
+ Addedcolor@3.2.1(transitive)
+ Addedcolor-name@1.1.4(transitive)
+ Addedcolor-string@1.9.1(transitive)
+ Addedcommander@5.1.0(transitive)
+ Addedcss-unit-converter@1.1.2(transitive)
+ Addeddetective@5.2.1(transitive)
+ Addedfs-extra@8.1.0(transitive)
+ Addedhtml-tags@3.3.1(transitive)
+ Addedis-arrayish@0.3.2(transitive)
+ Addedis-core-module@2.15.1(transitive)
+ Addednormalize.css@8.0.1(transitive)
+ Addedobject-hash@2.2.0(transitive)
+ Addedpath-parse@1.0.7(transitive)
+ Addedpostcss@7.0.32(transitive)
+ Addedpurgecss@2.3.0(transitive)
+ Addedreduce-css-calc@2.1.8(transitive)
+ Addedresolve@1.22.8(transitive)
+ Addedsimple-swizzle@0.2.2(transitive)
+ Addedsupports-preserve-symlinks-flag@1.0.0(transitive)
+ Addedtailwindcss@1.9.6(transitive)
+ Addedxtend@4.0.2(transitive)
- Removed@hapi/address@2.1.4(transitive)
- Removed@hapi/bourne@1.3.2(transitive)
- Removed@hapi/hoek@8.5.1(transitive)
- Removed@hapi/joi@15.1.1(transitive)
- Removed@hapi/topo@3.1.6(transitive)
- Removed@vue/cli-shared-utils@3.12.1(transitive)
- Removedajv@6.12.6(transitive)
- Removedansi-regex@2.1.1(transitive)
- Removedansi-styles@2.2.1(transitive)
- Removedarray-buffer-byte-length@1.0.1(transitive)
- Removedarraybuffer.prototype.slice@1.0.3(transitive)
- Removedasn1@0.2.6(transitive)
- Removedassert-plus@1.0.0(transitive)
- Removedasynckit@0.4.0(transitive)
- Removedavailable-typed-arrays@1.0.7(transitive)
- Removedaws-sign2@0.7.0(transitive)
- Removedaws4@1.13.2(transitive)
- Removedbabel-extract-comments@1.0.0(transitive)
- Removedbabel-plugin-syntax-object-rest-spread@6.13.0(transitive)
- Removedbabel-plugin-transform-object-rest-spread@6.26.0(transitive)
- Removedbabel-runtime@6.26.0(transitive)
- Removedbabylon@6.18.0(transitive)
- Removedbcrypt-pbkdf@1.0.2(transitive)
- Removedcall-bind@1.0.7(transitive)
- Removedcaseless@0.12.0(transitive)
- Removedchalk@1.1.3(transitive)
- Removedcli-cursor@2.1.0(transitive)
- Removedcli-spinners@2.9.2(transitive)
- Removedclone@1.0.4(transitive)
- Removedcombined-stream@1.0.8(transitive)
- Removedcomment-regex@1.0.1(transitive)
- Removedcore-js@2.6.12(transitive)
- Removedcore-util-is@1.0.2(transitive)
- Removedcross-spawn@6.0.5(transitive)
- Removedcss.escape@1.5.1(transitive)
- Removedcssesc@2.0.0(transitive)
- Removeddashdash@1.14.1(transitive)
- Removeddata-view-buffer@1.0.1(transitive)
- Removeddata-view-byte-length@1.0.1(transitive)
- Removeddata-view-byte-offset@1.0.0(transitive)
- Removeddefaults@1.0.4(transitive)
- Removeddefine-data-property@1.1.4(transitive)
- Removeddefine-properties@1.2.1(transitive)
- Removeddelayed-stream@1.0.0(transitive)
- Removedeasy-stack@1.0.1(transitive)
- Removedecc-jsbn@0.1.2(transitive)
- Removedend-of-stream@1.4.4(transitive)
- Removedes-abstract@1.23.3(transitive)
- Removedes-define-property@1.0.0(transitive)
- Removedes-errors@1.3.0(transitive)
- Removedes-object-atoms@1.0.0(transitive)
- Removedes-set-tostringtag@2.0.3(transitive)
- Removedes-to-primitive@1.2.1(transitive)
- Removedevent-pubsub@4.3.0(transitive)
- Removedexeca@1.0.0(transitive)
- Removedextend@3.0.2(transitive)
- Removedextsprintf@1.3.0(transitive)
- Removedfast-deep-equal@3.1.3(transitive)
- Removedfast-json-stable-stringify@2.1.0(transitive)
- Removedfor-each@0.3.3(transitive)
- Removedforever-agent@0.6.1(transitive)
- Removedform-data@2.3.3(transitive)
- Removedfs-extra@4.0.3(transitive)
- Removedfunction.prototype.name@1.1.6(transitive)
- Removedfunctions-have-names@1.2.3(transitive)
- Removedgather-stream@1.0.0(transitive)
- Removedget-intrinsic@1.2.4(transitive)
- Removedget-stream@4.1.0(transitive)
- Removedget-symbol-description@1.0.2(transitive)
- Removedgetpass@0.1.7(transitive)
- Removedglobalthis@1.0.4(transitive)
- Removedgopd@1.0.1(transitive)
- Removedhar-schema@2.0.0(transitive)
- Removedhar-validator@5.1.5(transitive)
- Removedhas-ansi@2.0.0(transitive)
- Removedhas-bigints@1.0.2(transitive)
- Removedhas-flag@1.0.0(transitive)
- Removedhas-property-descriptors@1.0.2(transitive)
- Removedhas-proto@1.0.3(transitive)
- Removedhas-symbols@1.0.3(transitive)
- Removedhas-tostringtag@1.0.2(transitive)
- Removedhttp-signature@1.2.0(transitive)
- Removedindexes-of@1.0.1(transitive)
- Removedinternal-slot@1.0.7(transitive)
- Removedis-array-buffer@3.0.4(transitive)
- Removedis-bigint@1.0.4(transitive)
- Removedis-boolean-object@1.1.2(transitive)
- Removedis-callable@1.2.7(transitive)
- Removedis-data-view@1.0.1(transitive)
- Removedis-date-object@1.0.5(transitive)
- Removedis-negative-zero@2.0.3(transitive)
- Removedis-number-object@1.0.7(transitive)
- Removedis-regex@1.1.4(transitive)
- Removedis-shared-array-buffer@1.0.3(transitive)
- Removedis-stream@1.1.0(transitive)
- Removedis-string@1.0.7(transitive)
- Removedis-symbol@1.0.4(transitive)
- Removedis-typed-array@1.1.13(transitive)
- Removedis-typedarray@1.0.0(transitive)
- Removedis-weakref@1.0.2(transitive)
- Removedis-wsl@1.1.0(transitive)
- Removedisarray@2.0.5(transitive)
- Removedisexe@2.0.0(transitive)
- Removedisstream@0.1.2(transitive)
- Removedjs-base64@2.6.4(transitive)
- Removedjs-message@1.0.7(transitive)
- Removedjs-queue@2.0.2(transitive)
- Removedjsbn@0.1.1(transitive)
- Removedjson-schema@0.4.0(transitive)
- Removedjson-schema-traverse@0.4.1(transitive)
- Removedjson-stringify-safe@5.0.1(transitive)
- Removedjsprim@1.4.2(transitive)
- Removedlaunch-editor@2.9.1(transitive)
- Removedlog-symbols@2.2.0(transitive)
- Removedlru-cache@5.1.1(transitive)
- Removedmime-db@1.52.0(transitive)
- Removedmime-types@2.1.35(transitive)
- Removedmimic-fn@1.2.0(transitive)
- Removednice-try@1.0.5(transitive)
- Removednode-ipc@9.2.1(transitive)
- Removednpm-run-path@2.0.2(transitive)
- Removedoauth-sign@0.9.0(transitive)
- Removedobject-inspect@1.13.2(transitive)
- Removedobject-keys@1.1.1(transitive)
- Removedobject.assign@4.1.5(transitive)
- Removedonetime@2.0.1(transitive)
- Removedopen@6.4.0(transitive)
- Removedora@3.4.0(transitive)
- Removedp-finally@1.0.0(transitive)
- Removedpath-key@2.0.1(transitive)
- Removedperfectionist@2.4.0(transitive)
- Removedperformance-now@2.1.0(transitive)
- Removedpossible-typed-array-names@1.0.0(transitive)
- Removedpostcss@5.2.18(transitive)
- Removedpostcss-scss@0.3.1(transitive)
- Removedpostcss-selector-parser@5.0.0(transitive)
- Removedpsl@1.9.0(transitive)
- Removedpump@3.0.2(transitive)
- Removedpunycode@2.3.1(transitive)
- Removedqs@6.5.3(transitive)
- Removedread-file-stdin@0.2.1(transitive)
- Removedregenerator-runtime@0.11.1(transitive)
- Removedregexp.prototype.flags@1.5.2(transitive)
- Removedrequest@2.88.2(transitive)
- Removedrequest-promise-core@1.1.4(transitive)
- Removedrequest-promise-native@1.0.9(transitive)
- Removedrestore-cursor@2.0.0(transitive)
- Removedsafe-array-concat@1.1.2(transitive)
- Removedsafe-buffer@5.2.1(transitive)
- Removedsafe-regex-test@1.0.3(transitive)
- Removedsafer-buffer@2.1.2(transitive)
- Removedsemver@5.7.26.3.1(transitive)
- Removedset-function-length@1.2.2(transitive)
- Removedset-function-name@2.0.2(transitive)
- Removedshebang-command@1.2.0(transitive)
- Removedshebang-regex@1.0.0(transitive)
- Removedshell-quote@1.8.1(transitive)
- Removedside-channel@1.0.6(transitive)
- Removedsignal-exit@3.0.7(transitive)
- Removedsource-map@0.5.7(transitive)
- Removedsshpk@1.18.0(transitive)
- Removedstealthy-require@1.1.1(transitive)
- Removedstring.prototype.padstart@3.1.6(transitive)
- Removedstring.prototype.repeat@0.2.0(transitive)
- Removedstring.prototype.trim@1.2.9(transitive)
- Removedstring.prototype.trimend@1.0.8(transitive)
- Removedstring.prototype.trimstart@1.0.8(transitive)
- Removedstrip-ansi@3.0.1(transitive)
- Removedstrip-comments@1.0.2(transitive)
- Removedstrip-eof@1.0.0(transitive)
- Removedsupports-color@2.0.03.2.3(transitive)
- Removedtailwindcss@0.7.4(transitive)
- Removedtough-cookie@2.5.0(transitive)
- Removedtunnel-agent@0.6.0(transitive)
- Removedtweetnacl@0.14.5(transitive)
- Removedtyped-array-buffer@1.0.2(transitive)
- Removedtyped-array-byte-length@1.0.1(transitive)
- Removedtyped-array-byte-offset@1.0.2(transitive)
- Removedtyped-array-length@1.0.6(transitive)
- Removedunbox-primitive@1.0.2(transitive)
- Removeduniq@1.0.1(transitive)
- Removeduri-js@4.4.1(transitive)
- Removeduuid@3.4.0(transitive)
- Removedvendors@1.0.4(transitive)
- Removedverror@1.10.0(transitive)
- Removedwcwidth@1.0.1(transitive)
- Removedwhich@1.3.1(transitive)
- Removedwhich-boxed-primitive@1.0.2(transitive)
- Removedwhich-typed-array@1.1.15(transitive)
- Removedwrite-file-stdout@0.0.2(transitive)
- Removedyallist@3.1.1(transitive)
Updatedtailwindcss@^1.0.0-beta.3