Inspired by #2819, #2829, and
https://github.com/pakornv/fresh-plugin-tailwindcss, I made minimal
modifications to the plugin-tailwind, I originally intended to update
based on #2829, but I was informed by the system that I couldn't push.
Due to the breaking changes in Tailwind v4, some PostCSS plugins are no
longer required. Additionally, I updated the syntax in the /www
directory. The /www directory now uses the updated plugin supported by
Tailwind v4.I think this has made initial progress.
# What This PR Solves
The Tailwind plugin has been updated to support Tailwind v4, and it is
currently functioning well both in the repository's www directory and in
the initialized project which for test.
## --patch-1
### 1. Dependency Optimization
- Removed `cssnano` dependency, using Tailwind v4's built-in
optimization(Based on @csvn 's suggestion)
- Removed `autoprefixer` dependency
- Updated `tailwind-plugin` version number
### 2. Build Configuration Adjustments
- Added `--node-modules-dir` parameter to `/www` task for Tailwind v4
support (Based on @marvinhagemeister 's suggestion)
- Added `--allow-scripts` parameter to enable `@tailwindcss/oxide`
execution
### 3. Code Adaptation
- Modified Tailwind-related code in `/www` to support Tailwind v4
- Updated dependency configuration in `deno.json`
### 4. Feature Restoration
- Added `imagescript` and `astral` dependencies to restore screenshot
functionality lost in previous PR updates
- Fixed the issue where the `tailwind-plugin` dependency was incorrectly
pointing to the JSR package instead of the local repository source code
in previous PR.
## --patch-2
- Upgraded Tailwind CSS to the latest version.
- Removed unnecessary dependencies.
- Enabled CSS minification by default when Fresh is in production mode.
- Updated docs/canary/examples/migration-guide.md to support the new
Tailwind plugin format.
- Updated init/src/init.ts to support the new Tailwind version and
plugin version, use new `@import "tailwindcss"`, and generate the new
plugin format.
- Updated init/src/init_test.ts: tests now expect `css` to match
`/tailwindcss/` instead of `/@tailwind/`.
- Removed plugin-tailwindcss/src/types.ts as it is no longer needed, and
updated plugin-tailwindcss/src/mod.ts and www/dev.ts to support the new
format.
Co-authored-by: Asher Gomez <ashersaupingomez@gmail.com>
## --patch-3
Addressing @marvinhagemeister feedback, this patch reverts the
unintended loss of PR #2960's changes caused by merge conflicts.
## --patch-4
I initialized a project according to the migration documentation and
used @fresh/update to test whether the plugin works properly with
v2-alpha-34. The results show that it works fine.
- The plugin is published at
jsr:@freshpress/fresh-plugin-tailwind@0.0.1-alpha.8.
- The test project is published at
https://github.com/SisyphusZheng/fresh-project-test/tree/main/fresh-project.
# How Testing Was Conducted
## Local Environment Testing
1. Environment Cleanup
```bash
rm -rf ./.cache/deno deno.lock node_modules
```
2. Test Execution
```bash
deno task www
```
3. Result Verification
- Checked functionality in local `/www` environment
- Confirmed all features working properly
## Code Inspection
- Passed `deno task ok` check
## This forked /www website is hosted and running on GitHub Codespaces,
with support for the latest code changes. You can check it out at:
https://silver-trout-pjr4jw7xx5x9299x6-8000.app.github.dev/
---------
Co-authored-by: 李嘉图·M·路 <146103794+Ricardo-M-Zheng@users.noreply.github.com>
Co-authored-by: deno-deploy[bot] <75045203+deno-deploy[bot]@users.noreply.github.com>
Co-authored-by: Asher Gomez <ashersaupingomez@gmail.com>
Co-authored-by: Marvin Hagemeister <marvin@deno.com>
Replaces the patterns below with consistent `AsyncDisposable` and `await
using` resource management for automatic cleanup.
- `await withTmpDir(async (dir) => { ... })` with `finally`
- Makes code a bit flatter, and reduces callback-hell a bit
- `await Deno.makeTempDir()` + `Deno.remove()`
- `await Deno.makeTempDir()`
Helps be more consistent in removing temporary folders. Among others,
ensures temp folders are removed in the tests below:
- `src/build_cache_test.ts`
- `src/dev/builder_test.ts`
- `src/dev/dev_build_cache_test.ts`
## TODO's
The `Deno.makeTempDir()` method is still used by `buildProd` as well,
but this method is used in the top module scope, where it does not work
correctly with `Deno.test` (it runs before the test methods). I removed
this part from the PR and leave this for later to avoid making the PR
too big.
-
https://github.com/csvn/fresh/blob/test%2Fdisposable-tmp-dirs/tests/test_utils.tsx/#L64
-
https://github.com/csvn/fresh/blob/test%2Fdisposable-tmp-dirs/www/main_test.ts/#L7
These changes simplify implementation logic of the init workflow and
mock `prompt()` and `console()` functionality in a more direct manner.
This makes things easier to reason about by jumping through fewer mental
hoops.
This commit updates several links which are outdated and now redirect to
different URLs on the updated Deno website and documentation.
There are a few dozen instances of URLs starting with
`https:://deno.land/x` and `https:://deno.land/std`. I left these alone
since they are dependencies. Would it make sense to update these from
the versions hosted at `deno.land` to their JSR equivalents, since that
is the new and preferred location of the Deno Standard Library packages
as well as other JavaScript/TypeScript packages used by Deno projects?
For example, the latest version of the Deno Standard Library is now
hosted at `https://jsr.io/@std` instead of `https://deno.land/std`.

---------
Co-authored-by: Marvin Hagemeister <hello@marvinh.dev>
From what I can see, `fsRoutes` uses the `FreshConfig.root` option by
default, so this property does not need to be specified. I also added
some JSDoc for the `dir` option in `fsRoutes()` as I understood it's
purpose.
Resolves https://github.com/denoland/fresh/issues/2771
Specifically the `init` test fails:
```
deno test -A ./init
```
Output:
```
error: No target files found.
----- output end -----
init - fmt, lint, and type check project ... FAILED (157ms)
init with tailwind - fmt, lint, and type check project ...
------- output -------
Task check deno fmt --check && deno lint && deno check **/*.ts && deno check **/*.tsx
error: No target files found.
----- output end -----
init with tailwind - fmt, lint, and type check project ... FAILED (136ms)
```
Seems to be a gitignore issue, and _probably_ relates to the new
features that ["lint an fmt respect
gitignore"](https://github.com/denoland/deno/pull/26897):
- the gitignore file in the fresh project has `tmp-*`
- the tmp directory created by the init test matches that pattern:
`tmp-${hash}`
- changing the tmp directory to `tmp_${hash}` resolves the issue 😄
The documentation for `MiddlewareFn` is out of date, because it
references a nonexistent `defineMiddleware` function. It's been updated
to reference the correct `define.middleware` function.
Additionally, I included an example of using this in the init project. I
also complicated the usage of `app.get` so that the function actually
uses the context. To make it clear to users of fresh 1 that this can be
equivalent to a file-based-route, I've included such a route as well.
The two new examples in `maini.ts` should make it much more clear to
fresh 1 users how the new system can work.
There were two issues with initialized projects:
1. not every file was formatted properly
2. linting wasn't passing when using `verbatim-module-syntax`. This
isn't enabled right now, due to it not having the `recommended` tag, but
it seems like a good idea. Actually initializing a project with this can
be done in a separate PR.