Skip to content

Commit d38951d

Browse files
authored
Fix #5975 (#5976)
Fixes issue with blank screen caused by missing `tailwind.css`.
1 parent 8c6fd60 commit d38951d

File tree

10 files changed

+107
-14
lines changed

10 files changed

+107
-14
lines changed

app/ide-desktop/eslint.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ const NAME = 'enso'
2424
* `yargs` and `react-hot-toast` are modules we explicitly want the default imports of.
2525
* `node:process` is here because `process.on` does not exist on the namespace import. */
2626
const DEFAULT_IMPORT_ONLY_MODULES =
27-
'node:process|chalk|string-length|yargs|yargs\\u002Fyargs|sharp|to-ico|connect|morgan|serve-static|create-servers|electron-is-dev|fast-glob|esbuild-plugin-alias|esbuild-plugin-time|esbuild-plugin-yaml|opener'
27+
'node:process|chalk|string-length|yargs|yargs\\u002Fyargs|sharp|to-ico|connect|morgan|serve-static|create-servers|electron-is-dev|fast-glob|esbuild-plugin-.+|opener'
2828
const ALLOWED_DEFAULT_IMPORT_MODULES = `${DEFAULT_IMPORT_ONLY_MODULES}|react-hot-toast`
2929
const OUR_MODULES = 'enso-content-config|enso-common'
3030
const RELATIVE_MODULES =

app/ide-desktop/lib/content/esbuild-config.ts

Lines changed: 50 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
*/
1111

1212
import * as childProcess from 'node:child_process'
13-
import * as fs from 'node:fs'
13+
import * as fs from 'node:fs/promises'
1414
import * as path from 'node:path'
1515
import * as url from 'node:url'
1616

@@ -28,6 +28,13 @@ import BUILD_INFO from '../../build.json' assert { type: 'json' }
2828

2929
export const THIS_PATH = path.resolve(path.dirname(url.fileURLToPath(import.meta.url)))
3030

31+
// =================
32+
// === Constants ===
33+
// =================
34+
35+
const TAILWIND_BINARY_PATH = '../../node_modules/.bin/tailwindcss'
36+
const TAILWIND_CSS_PATH = path.resolve(THIS_PATH, 'src', 'tailwind.css')
37+
3138
// =============================
3239
// === Environment variables ===
3340
// =============================
@@ -93,12 +100,51 @@ export function alwaysCopiedFiles(wasmArtifacts: string) {
93100
export async function* filesToCopyProvider(wasmArtifacts: string, assetsPath: string) {
94101
console.log('Preparing a new generator for files to copy.')
95102
yield* alwaysCopiedFiles(wasmArtifacts)
96-
for (const file of await fs.promises.readdir(assetsPath)) {
103+
for (const file of await fs.readdir(assetsPath)) {
97104
yield path.resolve(assetsPath, file)
98105
}
99106
console.log('Generator for files to copy finished.')
100107
}
101108

109+
// ======================
110+
// === Inline plugins ===
111+
// ======================
112+
113+
function esbuildPluginGenerateTailwind(args: Pick<Arguments, 'assetsPath'>): esbuild.Plugin {
114+
return {
115+
name: 'enso-generate-tailwind',
116+
setup: build => {
117+
// Required since `onStart` is called on every rebuild.
118+
let firstRun = true
119+
build.onStart(() => {
120+
if (firstRun) {
121+
const dest = path.join(args.assetsPath, 'tailwind.css')
122+
const config = path.resolve(THIS_PATH, 'tailwind.config.ts')
123+
console.log(`Generating tailwind css from '${TAILWIND_CSS_PATH}' to '${dest}'.`)
124+
const child = childProcess.spawn(`node`, [
125+
TAILWIND_BINARY_PATH,
126+
'-i',
127+
TAILWIND_CSS_PATH,
128+
'o',
129+
dest,
130+
'-c',
131+
config,
132+
'--minify',
133+
])
134+
firstRun = false
135+
return new Promise(resolve =>
136+
child.on('close', () => {
137+
resolve({})
138+
})
139+
)
140+
} else {
141+
return {}
142+
}
143+
})
144+
},
145+
}
146+
}
147+
102148
// ================
103149
// === Bundling ===
104150
// ================
@@ -125,6 +171,8 @@ export function bundlerOptions(args: Arguments) {
125171
esbuildPluginNodeGlobals.NodeGlobalsPolyfillPlugin({ buffer: true, process: true }),
126172
esbuildPluginAlias({ ensogl_app: ensoglAppPath }),
127173
esbuildPluginTime(),
174+
// This must run before the copy plugin so that the generated `tailwind.css` is used.
175+
esbuildPluginGenerateTailwind({ assetsPath }),
128176
esbuildPluginCopy.create(() => filesToCopyProvider(wasmArtifacts, assetsPath)),
129177
],
130178
define: {

app/ide-desktop/lib/content/package.json

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
"scripts": {
1818
"typecheck": "npx tsc --noEmit",
1919
"lint": "npx --yes eslint src",
20-
"build": "cd ../dashboard/src/authentication && npx tailwindcss -i src/styles/index.css -o ../../../../../../dist/gui/assets/tailwind.css -c tailwind.config.ts --minify && cd ../../../content && ts-node bundle.ts",
21-
"watch": "cd ../dashboard/src/authentication && npx tailwindcss -i src/styles/index.css -o ../../../../../../dist/gui/assets/tailwind.css -c tailwind.config.ts --minify && cd ../../../content && ts-node watch.ts",
20+
"build": "ts-node bundle.ts",
21+
"watch": "ts-node watch.ts",
2222
"start": "ts-node start.ts"
2323
},
2424
"dependencies": {
@@ -41,9 +41,9 @@
4141
"@types/ws": "^8.5.4",
4242
"@typescript-eslint/eslint-plugin": "^5.55.0",
4343
"@typescript-eslint/parser": "^5.55.0",
44+
"enso-authentication": "^1.0.0",
4445
"enso-copy-plugin": "^1.0.0",
4546
"enso-gui-server": "^1.0.0",
46-
"enso-authentication": "^1.0.0",
4747
"esbuild": "^0.15.14",
4848
"esbuild-copy-static-files": "^0.1.0",
4949
"esbuild-dev-server": "^0.3.0",
@@ -55,14 +55,15 @@
5555
"glob": "^8.0.3",
5656
"globals": "^13.20.0",
5757
"source-map-loader": "^4.0.1",
58+
"tailwindcss": "^3.2.7",
5859
"ts-loader": "^9.3.0",
5960
"ts-node": "^10.9.1",
6061
"typescript": "^4.9.3",
6162
"yaml-loader": "^0.8.0"
6263
},
6364
"optionalDependencies": {
65+
"esbuild-darwin-64": "^0.15.18",
6466
"esbuild-linux-64": "^0.15.18",
65-
"esbuild-windows-64": "^0.15.18",
66-
"esbuild-darwin-64": "^0.15.18"
67+
"esbuild-windows-64": "^0.15.18"
6768
}
6869
}

app/ide-desktop/lib/content/src/index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
<title>Enso</title>
3636
<link rel="stylesheet" href="/style.css" />
3737
<link rel="stylesheet" href="/docsStyle.css" />
38+
<link rel="stylesheet" href="/tailwind.css" />
3839
<script type="module" src="/index.js" defer></script>
3940
<script type="module" src="/run.js" defer></script>
4041
</head>

app/ide-desktop/lib/dashboard/src/authentication/tailwind.config.ts renamed to app/ide-desktop/lib/content/tailwind.config.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
/** @file Configuration for Tailwind. */
22
/** @type {import('tailwindcss').Config} */
33
module.exports = {
4-
content: ['./src/**/*.tsx'],
4+
// FIXME[sb]: Tailwind building should be in `dashboard/`.
5+
content: ['../dashboard/src/authentication/src/**/*.tsx'],
56
theme: {
67
extend: {},
78
},
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
22
"extends": "../../tsconfig.json",
3-
"include": ["../types", "."]
3+
"include": ["../types", ".", "tailwind.config.ts"]
44
}

app/ide-desktop/lib/dashboard/src/authentication/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
"main": "./src/index.tsx",
66
"exports": "./src/index.tsx",
77
"devDependencies": {
8-
"tailwindcss": "^3.2.6",
98
"typescript": "^4.9.3"
109
},
1110
"dependencies": {

app/ide-desktop/lib/dashboard/src/authentication/src/index.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
import * as React from "react";
1414
import * as reactDOM from "react-dom/client";
1515

16-
import "./styles/index.css";
1716
import * as loggerProvider from "./providers/logger";
1817
import * as platformModule from "./platform";
1918
import App, * as app from "./components/app";

app/ide-desktop/package-lock.json

Lines changed: 46 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)