ng-tailwindcss
Advanced tools
Comparing version 2.1.1 to 2.2.0
41
index.js
@@ -18,4 +18,5 @@ #!/usr/bin/env node | ||
.option('-p, --purge', 'run PurgeCSS with this build') | ||
.option('-c, --config <config>', 'relative path to alternate ng-tailwind.js file') | ||
.action((args) => { | ||
build({ purgeFlag: args.purge }) | ||
build({ purgeFlag: args.purge, configPath: args.config }) | ||
}) | ||
@@ -27,4 +28,5 @@ | ||
.description('Watches Tailwind files and rebuilds on changes') | ||
.action((cmd) => { | ||
watch() | ||
.option('-c, --config <config>', 'relative path to alternate ng-tailwind.js file') | ||
.action((args) => { | ||
watch({ configPath: args.config }) | ||
}) | ||
@@ -36,3 +38,3 @@ | ||
.description('Configure your tailwind setup using custom arguments or the default setup;\n\tRestart of development server required for changes to take effect') | ||
.option('-c, --config <config>', 'relative path to tailwind config js file') | ||
.option('-c, --config <config>', 'relative path to tailwind.config.js file') | ||
.option('-s, --source <source>', 'relative path to css source file') | ||
@@ -48,8 +50,25 @@ .option('-o, --output <output>', 'relative path to css output file (referenced in angular.json output array)') | ||
} | ||
const ngTwConfig = {} | ||
if (args.config) ngTwConfig.configJS = path.normalize(path.resolve(args.config)) | ||
if (args.source) ngTwConfig.sourceCSS = path.normalize(path.resolve(args.source)) | ||
if (args.output) ngTwConfig.outputCSS = path.normalize(path.resolve(args.output)) | ||
if (args.hasOwnProperty('purge') || args.unsetPurge) ngTwConfig.purge = args.purge || false | ||
if (args.sass) ngTwConfig.sass = args.sass || false | ||
if (args.config) { | ||
ngTwConfig.configJS = path.normalize(path.resolve(args.config)) | ||
} | ||
if (args.source) { | ||
ngTwConfig.sourceCSS = path.normalize(path.resolve(args.source)) | ||
} | ||
if (args.output) { | ||
ngTwConfig.outputCSS = path.normalize(path.resolve(args.output)) | ||
} | ||
if ({}.hasOwnProperty.call(args, 'purge') || args.unsetPurge) { | ||
ngTwConfig.purge = args.purge || false | ||
} | ||
if (args.sass) { | ||
ngTwConfig.sass = args.sass || false | ||
} | ||
configure(ngTwConfig, args.default) | ||
@@ -70,2 +89,3 @@ }) | ||
.description('Run PurgeCSS on your output file to eliminate unused CSS selectors') | ||
.option('-c, --config <config>', 'relative path to alternate ng-tailwind.js file') | ||
.option('-k, --keyframes', 'PurgeCSS will remove unused keyframes') | ||
@@ -78,3 +98,4 @@ .option('-f, --fontface', 'PurgeCSS will remove unused fontfaces') | ||
fontFace: args.fontFace, | ||
rejected: args.rejected | ||
rejected: args.rejected, | ||
configPath: args.config | ||
}) | ||
@@ -81,0 +102,0 @@ }) |
@@ -21,4 +21,7 @@ const exec = require('child_process').exec | ||
module.exports = ({ purgeFlag }) => { | ||
const ngTwFile = path.normalize(path.resolve(process.cwd(), 'ng-tailwind.js')) | ||
module.exports = ({ purgeFlag, configPath }) => { | ||
const ngTwFile = configPath | ||
? path.normalize(path.resolve(process.cwd(), configPath)) | ||
: path.normalize(path.resolve(process.cwd(), 'ng-tailwind.js')) | ||
const config = fs.existsSync(ngTwFile) && require(ngTwFile) | ||
@@ -33,3 +36,3 @@ | ||
if (config.purge || purgeFlag) purge({}) | ||
if (config.purge || purgeFlag) purge({ configPath }) | ||
@@ -40,3 +43,3 @@ return resolve(sourceFile) | ||
const sassBuild = () => new Promise((resolve, reject) => sass.render({ | ||
const sassBuild = (configPath) => new Promise((resolve, reject) => sass.render({ | ||
file: config.sourceCSS | ||
@@ -46,3 +49,5 @@ }, (err, result) => { | ||
const tempFile = path.normalize(path.resolve(process.cwd(), 'temporary-tailwind-css-file.css')) | ||
const tempFile = configPath | ||
? path.normalize(path.resolve(process.cwd(), configPath.replace(/([\w\-.]+[-.][\w\-.]+\.(\w+))/, 'temporary-tailwind-css-file.css'))) // puts temp file in same dir as config file | ||
: path.normalize(path.resolve(process.cwd(), 'temporary-tailwind-css-file.css')) | ||
@@ -52,3 +57,7 @@ fs.writeFile(tempFile, result.css, err => err ? reject(err) : console.info('Sass Compiled.') || resolve(tempFile)) | ||
const removeFile = (file) => fs.unlink(file, err => err && console.error(err)) | ||
const removeFile = (file) => { | ||
if (fs.existsSync(file)) { | ||
fs.unlink(file, err => err && console.error(err)) | ||
} | ||
} | ||
@@ -58,3 +67,3 @@ if (config) { | ||
sass | ||
? sassBuild().then(twBuild).then(removeFile).catch(err => err && console.error(err)) | ||
? sassBuild(configPath).then(twBuild).then(removeFile).catch(err => err && console.error(err)) | ||
: console.log('No sass compiler installed. Run `npm i -O node-sass` or `npm i -O sass` and try again.') | ||
@@ -61,0 +70,0 @@ } else { |
@@ -5,4 +5,6 @@ const Purgecss = require('purgecss') | ||
module.exports = ({ keyframes, fontFace, rejected }) => { | ||
const ngTwFile = path.normalize(path.resolve(process.cwd(), 'ng-tailwind.js')) | ||
module.exports = ({ keyframes, fontFace, rejected, configPath }) => { | ||
const ngTwFile = configPath | ||
? path.normalize(path.resolve(process.cwd(), configPath)) | ||
: path.normalize(path.resolve(process.cwd(), 'ng-tailwind.js')) | ||
@@ -9,0 +11,0 @@ if (fs.existsSync(ngTwFile)) { |
@@ -6,4 +6,6 @@ const chokidar = require('chokidar') | ||
module.exports = () => { | ||
const ngTwFile = path.normalize(path.resolve(process.cwd(), 'ng-tailwind.js')) | ||
module.exports = ({ configPath }) => { | ||
const ngTwFile = configPath | ||
? path.normalize(path.resolve(process.cwd(), configPath)) | ||
: path.normalize(path.resolve(process.cwd(), 'ng-tailwind.js')) | ||
@@ -18,3 +20,3 @@ if (fs.existsSync(ngTwFile)) { | ||
build({}) | ||
build({ configPath }) | ||
}) | ||
@@ -29,3 +31,3 @@ | ||
build({}) | ||
build({ configPath }) | ||
}) | ||
@@ -32,0 +34,0 @@ |
{ | ||
"name": "ng-tailwindcss", | ||
"version": "2.1.1", | ||
"version": "2.2.0", | ||
"preferGlobal": true, | ||
@@ -11,3 +11,5 @@ "bin": { | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
"test": "standard && echo 'All tests pass!'", | ||
"lint": "standard", | ||
"lint:fix": "standard --fix" | ||
}, | ||
@@ -33,7 +35,10 @@ "repository": { | ||
"dependencies": { | ||
"chokidar": "^3.0.0", | ||
"commander": "^3.0.0", | ||
"purgecss": "^1.3.0", | ||
"update-notifier": "^3.0.0" | ||
"chokidar": "^3.3.1", | ||
"commander": "^4.1.1", | ||
"purgecss": "^1.4.2", | ||
"update-notifier": "^4.1.0" | ||
}, | ||
"devDependencies": { | ||
"standard": "^14.3.1" | ||
} | ||
} |
@@ -6,7 +6,9 @@ # ng-tailwindcss | ||
> | ||
> - PurgeCSS, ready to rock "out of the box", but also fully configurable (and monorepo friendly) | ||
> - PurgeCSS, ready to rock "out of the box", but also fully configurable | ||
> | ||
> - Sass support with optional dependency on node-sass | ||
> - Sass support with optional dependency on [node-sass](https://www.npmjs.com/package/node-sass) or [dart-sass](https://www.npmjs.com/package/sass) | ||
> | ||
> - Defaults reflect Tailwind 1.0.0-stable file naming conventions (v2.0.0) | ||
> - Defaults reflect Tailwind 1.0.0-stable file naming conventions (ngtw v2.0.0+) | ||
> | ||
> - Angular Workspaces (and other monorepo structures) Support (ngtw v2.2.0+) | ||
@@ -286,3 +288,3 @@ ## Why Is This Necessary? | ||
### _A Note About Monorepos_ | ||
### Monorepo Support | ||
@@ -299,2 +301,13 @@ If you are working with a monorepo structure where the content you need PurgeCSS to examine is not necessarily in the `./src/` directory, you can use the `content` property to define the path to those directories. | ||
If you have sub-projects that require fine-tuning of your ng-tailwind.js options, then you can create alternate ng-tailwind.js files for those sub-projects and leverage them in your watch/build/purge commands with the option `--config (-c)`. For example, your package.json scripts might look like this: | ||
```js | ||
{ | ||
"start": "ng serve & ngtw watch", // serves up "main app" using the default ./ng-tailwind.js for configuration | ||
"start:other": "ng serve other & ngtw watch -c projects/other-app/other-ng-tailwind.js", // serves up sub-project in same monorepo with custom config file | ||
"build": "ngtw build && ng build", | ||
"build:other": "ngtw build other -c projects/other-app/other-ng-tailwind.js && ng build" | ||
} | ||
``` | ||
-------- | ||
@@ -365,2 +378,3 @@ | ||
--purge => -p | ||
--config => -c | ||
@@ -371,4 +385,6 @@ purge => p | ||
--rejected => -r | ||
--config => -c | ||
watch => w | ||
--config => -c | ||
scripts => s | ||
@@ -375,0 +391,0 @@ |
No tests
QualityPackage does not have any tests. This is a strong signal of a poorly maintained or low quality package.
Found 1 instance in 1 package
34375
10
338
0
396
1
+ Addedansi-styles@4.3.0(transitive)
+ Addedboxen@4.2.0(transitive)
+ Addedchalk@3.0.0(transitive)
+ Addedcolor-convert@2.0.1(transitive)
+ Addedcolor-name@1.1.4(transitive)
+ Addedcommander@4.1.1(transitive)
+ Addedconfigstore@5.0.1(transitive)
+ Addedcrypto-random-string@2.0.0(transitive)
+ Addeddot-prop@5.3.0(transitive)
+ Addedescape-goat@2.1.1(transitive)
+ Addedglobal-dirs@2.1.0(transitive)
+ Addedhas-flag@4.0.0(transitive)
+ Addedini@1.3.7(transitive)
+ Addedis-installed-globally@0.3.2(transitive)
+ Addedis-npm@4.0.0(transitive)
+ Addedis-obj@2.0.0(transitive)
+ Addedis-path-inside@3.0.3(transitive)
+ Addedis-typedarray@1.0.0(transitive)
+ Addedmake-dir@3.1.0(transitive)
+ Addedpupa@2.1.1(transitive)
+ Addedsemver-diff@3.1.1(transitive)
+ Addedsupports-color@7.2.0(transitive)
+ Addedterm-size@2.2.1(transitive)
+ Addedtype-fest@0.8.1(transitive)
+ Addedtypedarray-to-buffer@3.1.5(transitive)
+ Addedunique-string@2.0.0(transitive)
+ Addedupdate-notifier@4.1.3(transitive)
+ Addedwidest-line@3.1.0(transitive)
+ Addedwrite-file-atomic@3.0.3(transitive)
+ Addedxdg-basedir@4.0.0(transitive)
- Removedansi-regex@3.0.1(transitive)
- Removedboxen@3.2.0(transitive)
- Removedchalk@2.4.2(transitive)
- Removedcommander@3.0.2(transitive)
- Removedconfigstore@4.0.0(transitive)
- Removedcross-spawn@5.1.0(transitive)
- Removedcrypto-random-string@1.0.0(transitive)
- Removeddot-prop@4.2.1(transitive)
- Removedescape-string-regexp@1.0.5(transitive)
- Removedexeca@0.7.0(transitive)
- Removedget-stream@3.0.0(transitive)
- Removedglobal-dirs@0.1.1(transitive)
- Removedhas-flag@3.0.0(transitive)
- Removedini@1.3.8(transitive)
- Removedis-installed-globally@0.1.0(transitive)
- Removedis-npm@3.0.0(transitive)
- Removedis-obj@1.0.1(transitive)
- Removedis-path-inside@1.0.1(transitive)
- Removedis-stream@1.1.0(transitive)
- Removedisexe@2.0.0(transitive)
- Removedlru-cache@4.1.5(transitive)
- Removedmake-dir@1.3.0(transitive)
- Removednpm-run-path@2.0.2(transitive)
- Removedp-finally@1.0.0(transitive)
- Removedpath-is-inside@1.0.2(transitive)
- Removedpath-key@2.0.1(transitive)
- Removedpify@3.0.0(transitive)
- Removedpseudomap@1.0.2(transitive)
- Removedsemver@5.7.2(transitive)
- Removedsemver-diff@2.1.0(transitive)
- Removedshebang-command@1.2.0(transitive)
- Removedshebang-regex@1.0.0(transitive)
- Removedstring-width@2.1.1(transitive)
- Removedstrip-ansi@4.0.0(transitive)
- Removedstrip-eof@1.0.0(transitive)
- Removedsupports-color@5.5.0(transitive)
- Removedterm-size@1.2.0(transitive)
- Removedtype-fest@0.3.1(transitive)
- Removedunique-string@1.0.0(transitive)
- Removedupdate-notifier@3.0.1(transitive)
- Removedwhich@1.3.1(transitive)
- Removedwidest-line@2.0.1(transitive)
- Removedwrite-file-atomic@2.4.3(transitive)
- Removedxdg-basedir@3.0.0(transitive)
- Removedyallist@2.1.2(transitive)
Updatedchokidar@^3.3.1
Updatedcommander@^4.1.1
Updatedpurgecss@^1.4.2
Updatedupdate-notifier@^4.1.0