54 Commits

Author SHA1 Message Date
Geoffrey
0bcd628ec3
Avoid writing to output files when no changes (#6550)
* fix(cli): avoid write same output when no changes

* generalize outputFile

This function will check a cache, it will only write the file if:
- The modified timestamps changed since last time we wrote something.
  This is useful to know if something changed by another tool or
  manually without diffing the full file.
- The contents changed.

* further simplify checks

Turns out that reading files and comparing them is fairly fast and there
is no huge benefit over only using the Stats of the file and keeping
track of that information.

Thanks @kentcdodds!

Co-authored-by: Robin Malfait <malfait.robin@gmail.com>
2022-01-04 16:29:16 +01:00
Dany Castillo
de1bdb4f5d
Fix debug mode being active although explicitly disabled (#5837)
* fix debug mode being active although explicitly disabled

* also set debug mode correctly in sharedState
2021-10-25 11:25:25 +02:00
Brad Cornes
92df04d0c3
Fix CLI --content option (#5775)
* Add failing test

* Fix CLI `--content` option
2021-10-13 19:58:15 +01:00
Brad Cornes
f599430d56
Configure awaitWriteFinish for chokidar (#5774)
* Configure `awaitWriteFinish` for chokidar

* Enable `awaitWriteFinish` on Windows only
2021-10-13 12:59:26 +01:00
Robin Malfait
d94541cbf3
Handle old to new config when normalizing the config (#5658)
* immediately take the `safelist` values into account

Currently we had to manually add them in the `setupTrackingContext`,
`setupWatchingContext` and the `cli`.

This was a bit cumbersome, because the `safelist` function (to resolve
regex patterns) was implemented on the context. This means that we had
to do something like this:

```js
let changedContent = []
let context = createContext(config, changedContent)
for (let content of context.safelist()) {
  changedContent.push(content)
}
```

This just feels wrong in general, so now it is handled internally for
you which means that we can't mess it up anymore in those 3 spots.

* drop the dot from the extension

Our transformers and extractors are implemented for `html` for example.
However the `path.extname()` returns `.html`.

This isn't an issue by default, but it could be for with custom
extractors / transformers.

* normalize the configuration

* make shared cache local per extractor

* ensure we always have an `extension`

Defaults to `html`

* splitup custom-extractors test

* update old config structure to new structure

* ensure we validate the "old" structure, and warn if invalid

* add tests with "old" config, to ensure it keeps working

* add missing `content` object

* inline unnecessary function abstraction
2021-10-01 12:56:54 +02:00
Jonathan Reinink
cd5cb00266
Implement one-time logging to prevent duplicate warnings (#5661)
Co-Authored-By: Adam Wathan <4323180+adamwathan@users.noreply.github.com>
2021-09-30 21:16:01 -04:00
Robin Malfait
39ccd06141
Fix fallback argument in CLI (#5646)
I don't know exactly what happened here, but it seems like I screwed
this trivial fallback up in a spectacular way... anyway, here to fix it!
2021-09-29 23:33:43 +02:00
Brad Cornes
484acb3f6b
Fix using backslashes in content globs (#5628)
* Normalize content globs

* Update changelog
2021-09-29 14:13:10 +01:00
Robin Malfait
30badadd21
ensure that we fallback to the first argument without any flags (#5464) 2021-09-10 10:14:44 +02:00
Robin Malfait
691ed02f63
Remove AOT (#5340)
* make `jit` mode the default when no mode is specified

* unify JIT and AOT codepaths

* ensure `Object.entries` on undefined doesn't break

It could be that sometimes you don't have values in your config (e.g.: `presets: []`), this in turn will break some plugins where we assume we have a value.

* drop AOT specific tests

These tests are all covered by JIT mode already and were AOT specific.

* simplify tests, and add a few

Some of the tests were written for AOT specifically, some were missing. We also updated the way we write those tests, essentially making Tailwind a blackbox, by testing against the final output.
Now that JIT mode is the default, this is super fast because we only generate what is used, instead of partially testing in a 3MB file or building it all, then purging.

* add some todo's to make sure we warn in a few cases

* make `darkMode: 'media'`, the default

This also includes moving dark mode tests to its own dedicated file.

* remove PostCSS 7 compat mode

* update CLI to be JIT-first

* fix integration tests

This is not a _real_ fix, but it does solve the broken test for now.

* warn when using @responsive or @variants

* remove the JIT preview warning

* remove AOT-only code paths

* remove all `mode: 'jit'` blocks

Also remove `variants: {}` since they are not useful in `JIT` mode
anymore.

* drop unused dependencies

* rename `purge` to `content`

* remove static CDN builds

* mark `--purge` as deprecated in the CLI

This will still work, but a warning will be printed and it won't show up
in the `--help` output.

* cleanup nesting plugin

We don't have to duplicate it anymore since there is no PostCSS 7
version anymore.

* make sure integration tests run in band

* cleanup folder structure

* make sure nesting folder is available

* simplify resolving of purge/content information
2021-09-01 17:13:59 +02:00
José Valim
b280378c33
Abort the watcher if stdin is closed to avoid zombie processes (#4997)
* Abort the watcher if stdin is closed to avoid zombie processes

* Apply suggestions from code review
2021-08-23 14:35:28 -04:00
Arnout Roemers
aefd5f71cb
Enable purging when --purge option is supplied in CLI (#4772)
Do not require NODE_ENV to be set to 'production' as well, as using
the --purge option in the CLI should be explicit enough.

Co-authored-by: Arnout Roemers <roemers@zorgdomein.nl>
2021-06-23 14:12:06 -04:00
Robin Malfait
70ca673d96
ensure the CLI in watch mode keeps running when on error (#4693) 2021-06-18 08:46:00 -04:00
Robin Malfait
f4799a32e8
add tests for the --postcss option in the new CLI (#4607)
* add tests for the --postcss option in the new CLI

* add `oneOf` ability to the `arg()` functionality

By default, `arg()` doesn't have a way to define multiple types. We want
the possibility of using `--postcss` (Boolean) or `--postcss
./custom-path.js`. But by default this is not possible.

This commit will allow us to do a few things, mainly:
- Keep the same API using the `{ type: oneOf(String, Boolean), description: '...' }`
- Keep the `--help` output similar

What we did behind the scenes is make sure to put the non recognized
flags in the `_` arguments list. This is possible by doing `permissive:
true`. We then manually parse those and resolve the correct value.

* ensure that we can use a custom `--postcss ./with-custom-path.js`
2021-06-10 11:35:17 -04:00
Robin Malfait
6f1d5f03cb
prefer local plugins (#4598)
* prefer local plugins over bundled plugins

* hoist resolving of plugins

* drop `options` when local `cssnano` is found
2021-06-09 13:13:30 -04:00
Robin Malfait
8518fee9ea
implement purge safelist (#4580)
* fix --help output in tests

* add tests to ensure we can use `purge.safelist`

* implement the `purge.safelist` for strings

* proxy `purge.safelist` to `purge.options.safelist`

This allows us to have a similar API in `AOT` and `JIT` mode.

* only proxy `purge.safelist` to `purge.options.safelist` if
`purge.options.safelist` doesn't exists yet.
2021-06-09 10:00:09 -04:00
Brad Cornes
3569d49f7e
fix cli purge option when using commas (#4578) 2021-06-08 06:32:50 -04:00
Adam Wathan
40645d7dca Rename --files option in CLI to --purge 2021-06-07 14:01:59 -04:00
Adam Wathan
67ee5e033d Write to stdout in watch mode if no output file provided 2021-06-05 16:38:54 -04:00
Adam Wathan
bd20d2c0fa Don't reassign configPath 2021-06-04 12:52:53 -04:00
Adam Wathan
746a12602e
Improve new JIT-compatible CLI (#4558)
Co-authored-by: Robin Malfait <malfait.robin@gmail.com>
2021-06-04 10:28:09 -04:00
Robin Malfait
4528bdc2d8
Start of new CLI (#4526)
* Ignore workspace settings

* Parameterize setting up the context

* WIP

* WIP

* WIP

* WIP

* wip

* WIP

Co-Authored-By: Jesse Katsumata <niconico.clarinet@gmail.com>

* WIP

Co-Authored-By: Jesse Katsumata <niconico.clarinet@gmail.com>

* WIP

Co-Authored-By: Jesse Katsumata <niconico.clarinet@gmail.com>

* Update some comments

Co-Authored-By: Jesse Katsumata <niconico.clarinet@gmail.com>

* Fix bug

* WIP

* WIP'

* more things

* log console.time calls conditionally based on process.env.DEBUG

* add `init` command

* clean up when using --jit

* Make config file optional

* cleanup path.resolve calls

path.resolve('.') is the same as path.resolve(process.cwd(), '.')

* implement `--help`

* shush eslint

* drop unnecessary file

Co-authored-by: Adam Wathan <adam.wathan@gmail.com>
Co-authored-by: Jesse Katsumata <niconico.clarinet@gmail.com>
2021-06-01 14:02:23 +02:00
Adam Wathan
38b4eeb288 Prettier likes parens a lot now
git blame is now broken forever.
2020-10-16 15:39:44 -04:00
Matt Stypa
eb4da80ede Code style updates 2018-09-24 07:55:24 -05:00
Matt Stypa
1b1ae8abc9 When no output file is specified for the build command, the result will be piped to stdout 2018-09-23 22:00:50 -05:00
mattstypa
d91eea88fb Reverted changes to processTailwindFeatures that would impact Webpack watch ability. As a result all commands also became Promise based 2018-09-14 11:07:23 -05:00
Matt Stypa
a20b4519d4 Node hashbang is required for npm bin files 2018-09-14 06:38:13 -05:00
Matt Stypa
b71cfe711e CLI tool rewrite 2018-09-13 21:37:10 -05:00
David Mosher
862bce837e add test harness for cli.js and stdout bugfix
- when used on the CLI, lib/cli.js was writing the output of log
statements to STDOUT; this caused consumers of the CLI who wanted to
pipe the processed output (css) to other unix utilities to end up with
invalid CSS due to the log messages appearing at the start and end of
the files

- this commit fixes this by replacing `console.log` with `console.warn`
and `console.error`, which both write output to STDERR
2018-05-03 13:42:45 -04:00
Adam Wathan
6e7ae58910 Move container component to a built-in plugin 2018-03-12 15:34:34 -04:00
Adam Wathan
bc05473b37 Add dependencies, fix warnings 2018-03-07 09:37:01 -05:00
Adam Wathan
d8698f6144 Switch from var to let
Closes #281.
2017-12-04 10:44:50 -05:00
Jonathan Reinink
1faabc82b1 Switch to separate config import
Import default config from separate path (require('tailwindcss/defaultConfig')) to allow importing the default config without importing all of Tailwind, which causes errors with Webpack due to a dynamic require.
2017-11-14 08:03:31 -05:00
Jonathan Reinink
e9c7ce2c7d Add success message after tailwind init command 2017-11-10 07:36:30 -05:00
Adam Wathan
8ebc56741e Fix path issues in CLI 2017-11-08 08:27:00 -05:00
David Hemphill
06ed308c28 change print width to 100 characters 2017-11-06 15:02:02 -05:00
David Hemphill
79a2bb39e5 Reformat files 2017-11-06 15:02:02 -05:00
David Hemphill
9dbf5881cd fix eslint issues 2017-11-06 15:00:55 -05:00
David Hemphill
ec607968cf Add ESLinting and Prettier formatting and run an initial format on the codebase 2017-11-06 15:00:00 -05:00
Kalpa Perera
0c5ad514a9 Add file extension if not exists 2017-11-05 22:07:13 +05:30
Adam Wathan
f6b81ae35d Dynamically determine CLI tool version number 2017-11-02 11:35:48 -04:00
David Hemphill
66a2c1b9cb Hide catchall command from help 2017-11-01 17:26:59 -05:00
Adam Wathan
2d7b620f1e Fix issue with config option not being respected in tailwind build
Same issue as we were seeing with output files, I'm a dummy for missing
this and tagging.
2017-11-01 16:45:24 -04:00
Adam Wathan
24766911c1 Fix tailwind build CLI command
Moving to subcommands broke this without us noticing. It's probably a
good idea to add a big dirty integration test for this that just
executes the CLI command and makes sure the file was created.
2017-11-01 09:23:53 -04:00
Adam Wathan
782598319a Comment out requiring defaultConfig inside itself
Uncomment on init
2017-10-26 12:06:10 -04:00
Adam Wathan
7601b5564a Allow optional destination for init command, prevent overriding existing files 2017-10-24 07:39:09 -04:00
Adam Wathan
ba612c8953 WIP 2017-10-24 07:39:09 -04:00
Adam Wathan
244d7c09c9 Move defaultConfig to root so it's not processed by Babel 2017-10-24 07:39:09 -04:00
Adam Wathan
97905388b7 Fix bug where help was output even if matching command was found 2017-10-24 07:39:09 -04:00
Adam Wathan
01f37eb3fe Show help if no command is provided or if command is not found 2017-10-24 07:39:09 -04:00