Skip to content

Commit

Permalink
Merge pull request #1925 from embroider-build/new-index-html-format-css
Browse files Browse the repository at this point in the history
New `index.html` format - app css
  • Loading branch information
mansona committed May 20, 2024
2 parents 6b85eb1 + 6be1308 commit e01da0a
Show file tree
Hide file tree
Showing 14 changed files with 12 additions and 32 deletions.
4 changes: 0 additions & 4 deletions packages/compat/src/compat-app-builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,10 +174,8 @@ export class CompatAppBuilder {
rootURL: this.rootURL(),
prepare: (dom: JSDOM) => {
let scripts = [...dom.window.document.querySelectorAll('script')];
let styles = [...dom.window.document.querySelectorAll('link[rel*="stylesheet"]')] as HTMLLinkElement[];
return {
javascript: this.compatApp.findAppScript(scripts, entrypoint),
styles: this.compatApp.findAppStyles(styles, entrypoint),
implicitScripts: this.compatApp.findVendorScript(scripts, entrypoint),
testJavascript: this.compatApp.findTestScript(scripts),
};
Expand Down Expand Up @@ -361,8 +359,6 @@ export class CompatAppBuilder {
}
}

html.insertStyleLink(html.styles, `assets/${this.origAppPackage.name}.css`);

if (this.fastbootConfig) {
// any extra fastboot vendor files get inserted into our
// html.implicitScripts section, after the regular implicit script
Expand Down
13 changes: 0 additions & 13 deletions packages/compat/src/compat-app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -738,19 +738,6 @@ export default class CompatApp {
);
}

findAppStyles(styles: HTMLLinkElement[], entrypoint: string): HTMLLinkElement {
let style = styles.find(
style => this.withoutRootURL(style.href) === this.legacyEmberAppInstance.options.outputPaths.app.css.app
);
return throwIfMissing(
style,
this.legacyEmberAppInstance.options.outputPaths.app.css.app,
styles.map(s => s.href),
entrypoint,
'app css'
);
}

findVendorScript(scripts: HTMLScriptElement[], entrypoint: string): HTMLScriptElement {
const vendorScript = '/@embroider/core/vendor.js';
let vendor = scripts.find(script => this.withoutRootURL(script.src) === vendorScript);
Expand Down
5 changes: 1 addition & 4 deletions packages/core/src/ember-html.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ export interface EmberHTML {

// these are mandatory, the Ember app may need to put things into them.
javascript: Node;
styles: Node;
implicitScripts: Node;

// these are optional because you *may* choose to stick your implicit test
Expand Down Expand Up @@ -77,23 +76,21 @@ class Placeholder {
export class PreparedEmberHTML {
dom: JSDOM;
javascript: Placeholder;
styles: Placeholder;
implicitScripts: Placeholder;
testJavascript: Placeholder;

constructor(private asset: EmberAsset) {
this.dom = new JSDOM(readFileSync(asset.sourcePath, 'utf8'));
let html = asset.prepare(this.dom);
this.javascript = Placeholder.find(html.javascript);
this.styles = Placeholder.replacing(html.styles);
this.implicitScripts = Placeholder.find(html.implicitScripts);
this.testJavascript = html.testJavascript
? Placeholder.replacing(html.testJavascript)
: Placeholder.immediatelyAfter(this.javascript.end);
}

private placeholders(): Placeholder[] {
return [this.javascript, this.styles, this.implicitScripts, this.testJavascript];
return [this.javascript, this.implicitScripts, this.testJavascript];
}

clear() {
Expand Down
2 changes: 1 addition & 1 deletion packages/util/tests/dummy/app/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
{{content-for "head"}}

<link integrity="" rel="stylesheet" href="/@embroider/core/vendor.css">
<link integrity="" rel="stylesheet" href="{{rootURL}}assets/dummy.css">
<link integrity="" rel="stylesheet" href="/assets/dummy.css">

{{content-for "head-footer"}}
</head>
Expand Down
2 changes: 1 addition & 1 deletion test-packages/sample-transforms/tests/dummy/app/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
{{content-for "head"}}

<link integrity="" rel="stylesheet" href="/@embroider/core/vendor.css">
<link integrity="" rel="stylesheet" href="{{rootURL}}assets/dummy.css">
<link integrity="" rel="stylesheet" href="/assets/dummy.css">

{{content-for "head-footer"}}
</head>
Expand Down
2 changes: 1 addition & 1 deletion test-packages/sample-transforms/tests/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
{{content-for "test-head"}}

<link rel="stylesheet" href="/@embroider/core/vendor.css">
<link rel="stylesheet" href="{{rootURL}}assets/dummy.css">
<link rel="stylesheet" href="/assets/dummy.css">
<link rel="stylesheet" href="/@embroider/core/test-support.css">

{{content-for "head-footer"}}
Expand Down
2 changes: 1 addition & 1 deletion tests/addon-template/tests/dummy/app/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
{{content-for "head"}}

<link integrity="" rel="stylesheet" href="/@embroider/core/vendor.css">
<link integrity="" rel="stylesheet" href="{{rootURL}}assets/dummy.css">
<link integrity="" rel="stylesheet" href="/assets/dummy.css">

{{content-for "head-footer"}}
</head>
Expand Down
2 changes: 1 addition & 1 deletion tests/addon-template/tests/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
{{content-for "test-head"}}

<link rel="stylesheet" href="/@embroider/core/vendor.css">
<link rel="stylesheet" href="{{rootURL}}assets/dummy.css">
<link rel="stylesheet" href="/assets/dummy.css">
<link rel="stylesheet" href="/@embroider/core/test-support.css">

{{content-for "head-footer"}}
Expand Down
2 changes: 1 addition & 1 deletion tests/app-template/app/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
{{content-for "head"}}

<link integrity="" rel="stylesheet" href="/@embroider/core/vendor.css">
<link integrity="" rel="stylesheet" href="{{rootURL}}assets/app-template.css">
<link integrity="" rel="stylesheet" href="/assets/app-template.css">

{{content-for "head-footer"}}
</head>
Expand Down
2 changes: 1 addition & 1 deletion tests/app-template/tests/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
{{content-for "head"}} {{content-for "test-head"}}

<link rel="stylesheet" href="/@embroider/core/vendor.css" />
<link rel="stylesheet" href="{{rootURL}}assets/app-template.css" />
<link rel="stylesheet" href="/assets/app-template.css" />
<link rel="stylesheet" href="/@embroider/core/test-support.css" />

{{content-for "head-footer"}} {{content-for "test-head-footer"}}
Expand Down
2 changes: 1 addition & 1 deletion tests/fixtures/macro-test/tests/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
{{content-for "test-head"}}

<link rel="stylesheet" href="/@embroider/core/vendor.css">
<link rel="stylesheet" href="{{rootURL}}assets/app-template.css">
<link rel="stylesheet" href="/assets/app-template.css">
<link rel="stylesheet" href="/@embroider/core/test-support.css">

{{content-for "head-footer"}}
Expand Down
2 changes: 1 addition & 1 deletion tests/scenarios/compat-addon-classic-features-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ appScenarios
{{content-for "head"}}
<link integrity="" rel="stylesheet" href="/@embroider/core/vendor.css">
<link integrity="" rel="stylesheet" href="{{rootURL}}assets/app-template.css">
<link integrity="" rel="stylesheet" href="/assets/app-template.css">
{{content-for "head-footer"}}
</head>
Expand Down
2 changes: 1 addition & 1 deletion tests/ts-app-template/app/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
{{content-for "head"}}

<link integrity="" rel="stylesheet" href="/@embroider/core/vendor.css">
<link integrity="" rel="stylesheet" href="{{rootURL}}assets/ts-app-template.css">
<link integrity="" rel="stylesheet" href="/assets/ts-app-template.css">

{{content-for "head-footer"}}
</head>
Expand Down
2 changes: 1 addition & 1 deletion tests/ts-app-template/tests/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
{{content-for "test-head"}}

<link rel="stylesheet" href="/@embroider/core/vendor.css">
<link rel="stylesheet" href="{{rootURL}}assets/ts-app-template.css">
<link rel="stylesheet" href="/assets/ts-app-template.css">
<link rel="stylesheet" href="/@embroider/core/test-support.css">

{{content-for "head-footer"}}
Expand Down

0 comments on commit e01da0a

Please sign in to comment.