-
Notifications
You must be signed in to change notification settings - Fork 29.7k
[web] add --static-assets-url argument to build web #171638
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[web] add --static-assets-url argument to build web #171638
Conversation
|
This pull request has been changed to a draft. The currently pending flutter-gold status will not be able to resolve until a new commit is pushed or the change is marked ready for review again. For more guidance, visit Writing a golden file test for Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. |
|
Hey @harryterkelsen can you review this one? :) |
harryterkelsen
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mostly LGTM with one requested change
| 'static-assets-url', | ||
| help: | ||
| 'Used when serving the static assets from a different domain the application is hosted on. ' | ||
| 'The value has to start with http and end with a slash "/". ' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think having the static assets url start with http is a little too restrictive and also this documentation is somewhat ambiguous (can the --static-assets-url point to an https:// URL? Yes, but a reasonable person could read this documentation and think only http:// is allowed). I think just remove the check for startsWith('http'), keep the check for endsWith('/'), and update the documentation accordingly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey, @harryterkelsen. Thanks for your review! I just added a commit attending to your request.
|
Sorry for letting this drop off my radar! Thanks for your PR, I requested a small change |
|
Hello @harryterkelsen, sorry for pinging twice in a row. Do you mind reviewing this again? |
harryterkelsen
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM with nit
packages/flutter_tools/test/commands.shard/hermetic/build_web_test.dart
Outdated
Show resolved
Hide resolved
Closes flutter#171637 As mentioned in the issue, I am proposing a new argument to the flutter build web command: `--static-assets-url`. This argument would accept a full URL string ending with `/` as its value. During the build process, the Flutter tool would use this value to replace a dedicated placeholder within the `web/index.html` file (inspired by `--base-href` approach). Example Implementation: A developer would modify their `web/index.html` to use a new placeholder, for instance, `$FLUTTER_STATIC_ASSETS_URL`: ```html ... <body> <script> {{flutter_js}} {{flutter_build_config}} _flutter.loader.load({ config: { entryPointBaseUrl: "$FLUTTER_STATIC_ASSETS_URL", }, onEntrypointLoaded: async function (engineInitializer) { const appRunner = await engineInitializer.initializeEngine({ assetBase: "$FLUTTER_STATIC_ASSETS_URL", }); await appRunner.runApp(); }, }); </script> </body> ... ``` The build command would be run with the new flag: `flutter build web --static-assets-url="https://static.company.com/some-webapp/“` - and the resulting `build/web/index.html` would have the placeholder replaced: ```html ... <body> <script> {{flutter_js}} {{flutter_build_config}} _flutter.loader.load({ config: { entryPointBaseUrl: "https://static.company.com/some-webapp/", }, onEntrypointLoaded: async function (engineInitializer) { const appRunner = await engineInitializer.initializeEngine({ assetBase: "https://static.company.com/some-webapp/", }); await appRunner.runApp(); }, }); </script> </body> ... ```
flutter/flutter@92a6bfb...3821790 2025-08-08 [email protected] Use LLDB as the default debugging method for iOS 17+ and Xcode 26+ (flutter/flutter#173443) 2025-08-08 [email protected] Roll Fuchsia Linux SDK from i4vsuEGyP8Xeb5tiy... to HclTm0V8hgSpfqmtG... (flutter/flutter#173462) 2025-08-08 [email protected] Support launching a HTTPS URL (flutter/flutter#164720) 2025-08-08 [email protected] Roll Dart SDK from c48772a79e1f to 4b7b565eb468 (1 revision) (flutter/flutter#173454) 2025-08-08 [email protected] Roll Dart SDK from ba58b96a80d7 to c48772a79e1f (3 revisions) (flutter/flutter#173451) 2025-08-07 [email protected] Web dev proxy (flutter/flutter#172175) 2025-08-07 [email protected] Roll ICU from b929596baebf to 1b2e3e8a421e (7 revisions) (flutter/flutter#173436) 2025-08-07 [email protected] [A11y] TextField prefix icon and suffix icon create a sibling node' (flutter/flutter#173312) 2025-08-07 [email protected] [Android templates] Remove jetifier usage (flutter/flutter#173431) 2025-08-07 [email protected] Remove a couple of asserts from display_list_unittest (flutter/flutter#173381) 2025-08-07 [email protected] Fix ScaffoldGeometry null scale with noAnimation FAB (flutter/flutter#172914) 2025-08-07 [email protected] Prepare for iOS debugging with lldb and devicectl (flutter/flutter#173417) 2025-08-07 [email protected] Fix `ReorderableList` proxy animation for partial drag-back (flutter/flutter#172380) 2025-08-07 [email protected] [ios26]Do not report error for Info.plist key not found (flutter/flutter#172913) 2025-08-07 [email protected] Manual roll to 3.10.0-75.1.beta (flutter/flutter#173423) 2025-08-07 [email protected] [web] add --static-assets-url argument to build web (flutter/flutter#171638) 2025-08-07 [email protected] Adds deprecation for impeller opt out on android (flutter/flutter#173375) If this roll has caused a breakage, revert this CL and stop the roller using the controls here: https://autoroll.skia.org/r/flutter-packages Please CC [email protected],[email protected] on the revert to ensure that a human is aware of the problem. To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose To report a problem with the AutoRoller itself, please file a bug: https://issues.skia.org/issues/new?component=1389291&template=1850622 Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
Closes flutter#171637 As mentioned in the issue, I am proposing a new argument to the flutter build web command: `--static-assets-url`. This argument would accept a full URL string ending with `/` as its value. During the build process, the Flutter tool would use this value to replace a dedicated placeholder within the `web/index.html` file (inspired by `--base-href` approach). Example Implementation: A developer would modify their `web/index.html` to use a new placeholder, for instance, `$FLUTTER_STATIC_ASSETS_URL`: ```html ... <body> <script> {{flutter_js}} {{flutter_build_config}} _flutter.loader.load({ config: { entryPointBaseUrl: "$FLUTTER_STATIC_ASSETS_URL", }, onEntrypointLoaded: async function (engineInitializer) { const appRunner = await engineInitializer.initializeEngine({ assetBase: "$FLUTTER_STATIC_ASSETS_URL", }); await appRunner.runApp(); }, }); </script> </body> ... ``` The build command would be run with the new flag: `flutter build web --static-assets-url="https://static.company.com/some-webapp/“` - and the resulting `build/web/index.html` would have the placeholder replaced: ```html ... <body> <script> {{flutter_js}} {{flutter_build_config}} _flutter.loader.load({ config: { entryPointBaseUrl: "https://static.company.com/some-webapp/", }, onEntrypointLoaded: async function (engineInitializer) { const appRunner = await engineInitializer.initializeEngine({ assetBase: "https://static.company.com/some-webapp/", }); await appRunner.runApp(); }, }); </script> </body> ... ```
Closes flutter#171637 As mentioned in the issue, I am proposing a new argument to the flutter build web command: `--static-assets-url`. This argument would accept a full URL string ending with `/` as its value. During the build process, the Flutter tool would use this value to replace a dedicated placeholder within the `web/index.html` file (inspired by `--base-href` approach). Example Implementation: A developer would modify their `web/index.html` to use a new placeholder, for instance, `$FLUTTER_STATIC_ASSETS_URL`: ```html ... <body> <script> {{flutter_js}} {{flutter_build_config}} _flutter.loader.load({ config: { entryPointBaseUrl: "$FLUTTER_STATIC_ASSETS_URL", }, onEntrypointLoaded: async function (engineInitializer) { const appRunner = await engineInitializer.initializeEngine({ assetBase: "$FLUTTER_STATIC_ASSETS_URL", }); await appRunner.runApp(); }, }); </script> </body> ... ``` The build command would be run with the new flag: `flutter build web --static-assets-url="https://static.company.com/some-webapp/“` - and the resulting `build/web/index.html` would have the placeholder replaced: ```html ... <body> <script> {{flutter_js}} {{flutter_build_config}} _flutter.loader.load({ config: { entryPointBaseUrl: "https://static.company.com/some-webapp/", }, onEntrypointLoaded: async function (engineInitializer) { const appRunner = await engineInitializer.initializeEngine({ assetBase: "https://static.company.com/some-webapp/", }); await appRunner.runApp(); }, }); </script> </body> ... ```
Closes flutter#171637 As mentioned in the issue, I am proposing a new argument to the flutter build web command: `--static-assets-url`. This argument would accept a full URL string ending with `/` as its value. During the build process, the Flutter tool would use this value to replace a dedicated placeholder within the `web/index.html` file (inspired by `--base-href` approach). Example Implementation: A developer would modify their `web/index.html` to use a new placeholder, for instance, `$FLUTTER_STATIC_ASSETS_URL`: ```html ... <body> <script> {{flutter_js}} {{flutter_build_config}} _flutter.loader.load({ config: { entryPointBaseUrl: "$FLUTTER_STATIC_ASSETS_URL", }, onEntrypointLoaded: async function (engineInitializer) { const appRunner = await engineInitializer.initializeEngine({ assetBase: "$FLUTTER_STATIC_ASSETS_URL", }); await appRunner.runApp(); }, }); </script> </body> ... ``` The build command would be run with the new flag: `flutter build web --static-assets-url="https://static.company.com/some-webapp/“` - and the resulting `build/web/index.html` would have the placeholder replaced: ```html ... <body> <script> {{flutter_js}} {{flutter_build_config}} _flutter.loader.load({ config: { entryPointBaseUrl: "https://static.company.com/some-webapp/", }, onEntrypointLoaded: async function (engineInitializer) { const appRunner = await engineInitializer.initializeEngine({ assetBase: "https://static.company.com/some-webapp/", }); await appRunner.runApp(); }, }); </script> </body> ... ```
Closes flutter#171637 As mentioned in the issue, I am proposing a new argument to the flutter build web command: `--static-assets-url`. This argument would accept a full URL string ending with `/` as its value. During the build process, the Flutter tool would use this value to replace a dedicated placeholder within the `web/index.html` file (inspired by `--base-href` approach). Example Implementation: A developer would modify their `web/index.html` to use a new placeholder, for instance, `$FLUTTER_STATIC_ASSETS_URL`: ```html ... <body> <script> {{flutter_js}} {{flutter_build_config}} _flutter.loader.load({ config: { entryPointBaseUrl: "$FLUTTER_STATIC_ASSETS_URL", }, onEntrypointLoaded: async function (engineInitializer) { const appRunner = await engineInitializer.initializeEngine({ assetBase: "$FLUTTER_STATIC_ASSETS_URL", }); await appRunner.runApp(); }, }); </script> </body> ... ``` The build command would be run with the new flag: `flutter build web --static-assets-url="https://static.company.com/some-webapp/“` - and the resulting `build/web/index.html` would have the placeholder replaced: ```html ... <body> <script> {{flutter_js}} {{flutter_build_config}} _flutter.loader.load({ config: { entryPointBaseUrl: "https://static.company.com/some-webapp/", }, onEntrypointLoaded: async function (engineInitializer) { const appRunner = await engineInitializer.initializeEngine({ assetBase: "https://static.company.com/some-webapp/", }); await appRunner.runApp(); }, }); </script> </body> ... ```
Closes #171637
As mentioned in the issue, I am proposing a new argument to the flutter build web command:
--static-assets-url.This argument would accept a full URL string ending with
/as its value. During the build process, the Flutter tool would use this value to replace a dedicated placeholder within theweb/index.htmlfile (inspired by--base-hrefapproach).Example Implementation:
A developer would modify their
web/index.htmlto use a new placeholder, for instance,$FLUTTER_STATIC_ASSETS_URL:The build command would be run with the new flag:
flutter build web --static-assets-url="https://static.company.com/some-webapp/“- and the resultingbuild/web/index.htmlwould have the placeholder replaced: