Skip to content

Commit 70094ef

Browse files
committed
Use higher JS optimization level in release builds
1 parent a7bb5a8 commit 70094ef

File tree

4 files changed

+38
-1
lines changed

4 files changed

+38
-1
lines changed

site/build.yaml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,23 @@ builders:
77
- "lib/src/style_hash.dart"
88
auto_apply: root_package
99
build_to: source
10+
11+
targets:
12+
$default:
13+
builders:
14+
build_web_compilers:entrypoint:
15+
dev_options:
16+
compilers:
17+
dartdevc:
18+
release_options:
19+
# Use production compilers for release builds and
20+
# ensure kReleaseMode in jaspr is enabled.
21+
compilers:
22+
dart2js:
23+
args:
24+
- --no-source-maps
25+
- -O4
26+
- -Djaspr.flags.release=true
27+
# Disable for now.
28+
# dart2wasm:
29+
# args: [-O2, -Djaspr.flags.release=true]

site/lib/src/style_hash.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
// dart format off
33

44
/// The generated hash of the `main.css` file.
5-
const generatedStylesHash = 'nvTevrLjFn98';
5+
const generatedStylesHash = 'ugxj95DjrnBJ';

tool/dash_site/lib/src/commands/build.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ final class BuildSiteCommand extends Command<int> {
4343
'run',
4444
'jaspr_cli:jaspr',
4545
'build',
46+
// Use build_web_compiler options specified in build.yaml instead of
47+
// those specified by jaspr_cli.
48+
'--no-managed-build-options',
4649
'--sitemap-domain=https://docs.flutter.dev',
4750
'--dart-define=PRODUCTION=$productionRelease',
4851
],

tool/dash_site/lib/src/commands/serve.dart

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,18 @@ final class ServeSiteCommand extends Command<int> {
1515
@override
1616
String get name => 'serve';
1717

18+
ServeSiteCommand() {
19+
argParser.addFlag(
20+
'release',
21+
defaultsTo: false,
22+
help: 'Build with compilers used for release builds instead of dartdevc.',
23+
);
24+
}
25+
1826
@override
1927
Future<int> run() async {
28+
final release = argResults!.flag('release');
29+
2030
installJasprCliIfNecessary();
2131

2232
final process = await Process.start(
@@ -27,7 +37,11 @@ final class ServeSiteCommand extends Command<int> {
2737
'run',
2838
'jaspr_cli:jaspr',
2939
'serve',
40+
// Use build_web_compiler options specified in build.yaml instead of
41+
// those specified by jaspr_cli.
42+
'--no-managed-build-options',
3043
'--dart-define=PRODUCTION=false',
44+
if (release) '--release',
3145
],
3246
workingDirectory: 'site',
3347
runInShell: true,

0 commit comments

Comments
 (0)