ng-tailwindcss
Advanced tools
Comparing version 1.0.0 to 1.0.1
12
index.js
#!/usr/bin/env node | ||
const child = require('child_process') | ||
const program = require('commander') | ||
const watch = require('./lib/watch') | ||
const build = require('./lib/build') | ||
const scripts = require('./lib/scripts') | ||
const configure = require('./lib/configure') | ||
@@ -41,2 +41,10 @@ | ||
program.parse(process.argv) | ||
program | ||
.command('scripts') | ||
.alias('s') | ||
.description('Automatically inserts ng-tailwindcss the default scripts into your package.json') | ||
.action((cmd) => { | ||
scripts() | ||
}) | ||
program.parse(process.argv) |
@@ -16,2 +16,2 @@ const exec = require('child_process').exec | ||
} | ||
} | ||
} |
@@ -27,3 +27,3 @@ const fs = require('fs') | ||
`, err => { | ||
if (err) console.error('Error updating ng-tailwind.js:', err); | ||
if (err) console.error('Error updating ng-tailwind.js:', err) | ||
} | ||
@@ -45,3 +45,3 @@ ) | ||
`, err => { | ||
if (err) console.error('Error updating ng-tailwind.js:', err); | ||
if (err) console.error('Error updating ng-tailwind.js:', err) | ||
} | ||
@@ -62,6 +62,6 @@ ) | ||
`, err => { | ||
if (err) console.error('Error creating ng-tailwind.js:', err); | ||
if (err) console.error('Error creating ng-tailwind.js:', err) | ||
} | ||
) | ||
} | ||
} | ||
} |
@@ -20,2 +20,2 @@ const chokidar = require('chokidar') | ||
} | ||
} | ||
} |
{ | ||
"name": "ng-tailwindcss", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"preferGlobal": true, | ||
@@ -34,2 +34,2 @@ "bin": { | ||
} | ||
} | ||
} |
@@ -13,13 +13,9 @@ # ng-tailwindcss | ||
ng-tailwindcss configure | ||
touch src/tailwind.css | ||
touch src/tailwind.css | ||
``` | ||
Put all your [tailwind imports](https://tailwindcss.com/docs/installation/#3-use-tailwind-in-your-css) in `src/tailwind.css` and add/adjust these scripts in your package.json: | ||
Put all your [tailwind imports](https://tailwindcss.com/docs/installation/#3-use-tailwind-in-your-css) in `src/tailwind.css` and run: | ||
``` | ||
scripts: { | ||
"prestart": "ng-tailwindcss build", | ||
"start": "ng serve & ng-tailwindcss watch", | ||
"build": "ng-tailwindcss build && ng build" | ||
} | ||
ng-tailwindcss scripts | ||
``` | ||
@@ -34,6 +30,6 @@ | ||
2. If you don't already have a project up and running, start your angular project (assumes angular cli is already installed globally): | ||
2. If you don't already have an angular project up and running, start your angular project (assumes angular cli is already installed globally): | ||
`ng new angular-meets-tailwind` | ||
3. Follow Steps 1-3 from the Tailwind Installation Instructions: [Install Tailwind](https://tailwindcss.com/docs/installation#1-install-tailwind-via-npm) (`npm i tailwindcss -D`) and [initialize](https://tailwindcss.com/docs/installation#2-create-a-tailwind-config-file) (`./node_modules/.bin/tailwind init`) and [use tailwind in your _source_ css files](https://tailwindcss.com/docs/installation#3-use-tailwind-in-your-css). | ||
3. Follow Steps 1-3 from the Tailwind Installation Instructions: [Install Tailwind](https://tailwindcss.com/docs/installation#1-install-tailwind-via-npm) (`npm i tailwindcss -D`), [initialize](https://tailwindcss.com/docs/installation#2-create-a-tailwind-config-file) (`./node_modules/.bin/tailwind init`), and [use tailwind in your _source_ css files](https://tailwindcss.com/docs/installation#3-use-tailwind-in-your-css). | ||
A recommendation for new projects (no prior stylesheet changes) is to `touch src/tailwind.css` and use that file for all global styles and [component classes](https://tailwindcss.com/docs/extracting-components). | ||
@@ -43,41 +39,30 @@ | ||
``` | ||
ng-tailwindcss configure --config ./path/to/whatever-you-named-tailwind-config.js --source ./path/to/your-tailwind-source.css --output ./path/to/whatever-you-call-it.css | ||
``` | ||
``` | ||
ng-tailwindcss configure --config ./path/to/whatever-you-named-tailwind-config.js --source ./path/to/your-tailwind-source.css --output ./path/to/whatever-you-call-it.css | ||
``` | ||
You can alias your commands or argument flags thus: | ||
This will result in an `ng-tailwind.js` file at your project's root: | ||
``` | ||
configure => c | ||
--config => -c | ||
--source => -s | ||
--output => -o | ||
``` | ||
module.exports = { | ||
configJS: './path/to/whatever-you-named-tailwind-config.js', | ||
sourceCSS: './path/to/your-tailwind-source.css', | ||
outputCSS: './path/to/whatever-you-call-it.css' | ||
} | ||
``` | ||
watch => w | ||
build => b | ||
``` | ||
_See Configuration Below for More Details and Implications for Existing Angular Projects_ | ||
This will result in an `ng-tailwind.js` file at your project's root: | ||
``` | ||
module.exports = { | ||
configJS: './path/to/whatever-you-named-tailwind-config.js', | ||
sourceCSS: './path/to/your-tailwind-source.css', | ||
outputCSS: './path/to/whatever-you-call-it.css' | ||
} | ||
``` | ||
_See Configuration Below for More Details and Implications for Existing Angular Projects_ | ||
5. Add or adjust these scripts in your package.json: | ||
``` | ||
scripts: { | ||
"prestart": "ng-tailwindcss build", | ||
"start": "ng serve & ng-tailwindcss watch", | ||
"build": "ng-tailwindcss build && ng build" | ||
} | ||
``` | ||
``` | ||
scripts: { | ||
"prestart": "ng-tailwindcss build", | ||
"start": "ng serve & ng-tailwindcss watch", | ||
"build": "ng-tailwindcss build && ng build" | ||
} | ||
``` | ||
or simply run `ng-tailwindcss scripts` to have these adjustments made automatically in your `package.json`. | ||
Now using `npm start` for your development server will ensure your tailwind files are being watched and built with your project, and you can still rely on the angular-cli for everything else (no `ng eject`! yay!). | ||
Now using `npm start` for your development server will ensure your tailwind files are being watched and built with your project, and you can still rely on the angular-cli for everything else (no `ng eject`! yay!). | ||
@@ -102,4 +87,21 @@ 6. Keep calm and angular on. | ||
### Command Aliases | ||
You can alias your commands or argument flags thus: | ||
``` | ||
configure => c | ||
--config => -c | ||
--source => -s | ||
--output => -o | ||
watch => w | ||
build => b | ||
scripts => s | ||
--help => -h | ||
``` | ||
`--help` provides descriptions of each command or argument. | ||
## Contributing | ||
Yes, please. |
10778
7
168
103
1
8