dart-lang / webdev

A CLI for Dart web development.
https://pub.dev/packages/webdev
213 stars 71 forks source link

[SUPPORT] Can this be used with a flutter project? #2370

Closed gcb closed 5 months ago

gcb commented 5 months ago

Hi. Need help understanding why webdev is failing to set href for a web build.

 $ dart pub global run webdev:webdev serve  --no-launch-in-chrome -vvv --log-requests
[INFO] Connecting to the build daemon...
[INFO] Generating build script...
[INFO] Generating build script completed, took 256ms
[INFO]
[INFO] Starting daemon...
[INFO] BuildDefinition: Initializing inputs
[INFO] BuildDefinition: Reading cached asset graph...
[INFO] BuildDefinition: Reading cached asset graph completed, took 226ms

[INFO] BuildDefinition: Checking for updates since last build...
[INFO] BuildDefinition: Checking for updates since last build completed, took 906ms

[SEVERE] Initializing inputs
[SEVERE] Reading cached asset graph...
[SEVERE] Reading cached asset graph completed, took 226ms
[SEVERE]
[SEVERE] Checking for updates since last build...
[SEVERE] Checking for updates since last build completed, took 906ms
[SEVERE]
[SEVERE] Setting up file watchers...
[SEVERE] Setting up file watchers completed, took 2ms
[SEVERE]
[INFO] Registering build targets...
[INFO] Starting initial build...
[INFO] Starting resource servers...
[INFO] Serving `web` on http://0.0.0.0:8080

[INFO] About to build [web]...
[INFO] Build: Running build...
[INFO] Build: Running build completed, took 291ms

[INFO] Build: Caching finalized dependency graph...
[INFO] Build: Caching finalized dependency graph completed, took 227ms

[INFO] Build: Succeeded after 524ms with 0 outputs (3260 actions)

[INFO] -----------------------------------------------------------------

... GET     [200] /
... GET     [404] /flutter.js

(also not sure why the verbose log items show up as SEVERE instead of something like DEBUG. Edit: those messages seem to come from dart-lang/build)

results in

$ curl http://127.0.0.1:8080
...
  <base href="$FLUTTER_BASE_HREF">
...
  <meta name="apple-mobile-web-app-title" content="Correct project name from pubspec">
...
    const serviceWorkerVersion = null;
...

pubspec.yaml:

name: testD7
description: "testing 123"
publish_to: 'none'

version: 1.0.0+1

environment:
  sdk: ^3.2.6
  flutter: ^3.16.0

dependencies:
  flutter:
    sdk: flutter
  cupertino_icons: ^1.0.2

dev_dependencies:
  flutter_test:
    sdk: flutter
  integration_test:
    sdk: flutter
  flutter_lints: ^2.0.0
  # global webdev: ^3.4.0, which have the following two deps
  build_runner: ^2.4.0
  build_web_compilers: ^4.0.4

flutter:
  uses-material-design: true
$ flutter build web --no-tree-shake-icons --web-renderer html --release
$ curl http://127.0.0.1:8000
...
  <base href="/">
...
    const serviceWorkerVersion = "3819282140";
...
gcb commented 5 months ago

I get the same things using flutter pub global run instead of dart

gcb commented 5 months ago

same results moving webdev into the dev_deps and using dart run webdev serve

Also, forgot to mention, project was just created with the versions mentioned on the pubspec with flutter create ... --template=app

[✓] Flutter (Channel stable, 3.16.9, on Arch Linux 6.7.2-arch1-1, locale en_US.UTF-8)
    • Flutter version 3.16.9 on channel stable at /home/arch/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 41456452f2 (11 days ago), 2024-01-25 10:06:23 -0800
    • Engine revision f40e976bed
    • Dart version 3.2.6
    • DevTools version 2.28.5
gcb commented 5 months ago

found some outdate guides that mention the need for a main.dart scaffolding in web/ that is not provided by flutter create nor webserve serve

but they also mention a repo that doesn't exist anymore: https://github.com/flutter/flutter_web

parlough commented 5 months ago

package:webdev is intended for use by non-Flutter Dart web applications. For developing Flutter web apps you should generally use their standard flutter run -d <browser> and flutter build web commands.

Is there something specific you're trying to do that isn't working with those commands?

gcb commented 5 months ago

Simply serve with the webserve debuger instance without a locally installed chrome. Basically a headless flutter run -d

edit: looking at the right sources on the flutter side figured out i can get this to work with flutter run -d web-server and then use the undocumented params --web-port and --web-hostname for port and listen address. I think this cover the need I had to get this working

edit2: spoke too soon. With the flutter tooling there's no option to select --debug-extension or --debug here. It always tries to force --debug-extension, which is also not desirable.

elliette commented 5 months ago

Hi @gcb - as @parlough mentioned WebDev is intended to build and serve non-Flutter Dart web apps. Could you open a bug in https://github.com/flutter/flutter describing the functionality you would like? Thanks!