Skip to content

Commit 3591cb2

Browse files
LekoArtstyhopp
authored andcommitted
fix(gatsby): Use correct settings for yaml-loader (#37454)
* fix * add e2e test (cherry picked from commit 3ef4f44)
1 parent efdc5fa commit 3591cb2

File tree

4 files changed

+35
-1
lines changed

4 files changed

+35
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
describe(`webpack-loader: yaml`, () => {
2+
beforeEach(() => {
3+
cy.visit(`/webpack-loader/yaml/`).waitForRouteChange()
4+
})
5+
6+
it(`outputs the YAML file as JSON`, () => {
7+
cy.getTestElement(`webpack-loader-yaml`)
8+
.invoke(`text`)
9+
.should(`eq`, `[{"name":"Paul"},{"name":"Leto II"},{"name":"Ghanima"},{"name":"Alia"}]`)
10+
})
11+
})
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import * as React from "react"
2+
import Layout from "../../components/layout"
3+
4+
import inputYaml from "../../test-files/input.yaml"
5+
6+
const YamlPage = () => (
7+
<Layout>
8+
<pre>
9+
<code data-testid="webpack-loader-yaml">
10+
{JSON.stringify(inputYaml, null, 0)}
11+
</code>
12+
</pre>
13+
</Layout>
14+
)
15+
16+
export default YamlPage
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
- name: Paul
2+
- name: Leto II
3+
- name: Ghanima
4+
- name: Alia

packages/gatsby/src/utils/webpack-utils.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -232,8 +232,11 @@ export const createWebpackUtils = (
232232
},
233233
yaml: (options = {}) => {
234234
return {
235-
options,
236235
loader: require.resolve(`yaml-loader`),
236+
options: {
237+
asJSON: true,
238+
...options,
239+
},
237240
}
238241
},
239242

0 commit comments

Comments
 (0)