Skip to content

Commit 9fa8cd3

Browse files
Calderism-allanson
authored andcommitted
Topics/output dir (#4756)
* Give the possibility to add a --output website for build and develop Signed-off-by: Wetteren Rémi <[email protected]> * create folder is build directory doesn't exist Signed-off-by: Wetteren Rémi <[email protected]> * checking process env first * Trigger netlify rebuild
1 parent 6f8cdd3 commit 9fa8cd3

File tree

35 files changed

+122
-70
lines changed

35 files changed

+122
-70
lines changed

docs/docs/building-with-components.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,9 +161,10 @@ import React from "react";
161161
import favicon from "./favicon.png";
162162

163163
let inlinedStyles = "";
164+
const buildDirectory = process.env.GATSBY_BUILD_DIR || `public`
164165
if (process.env.NODE_ENV === "production") {
165166
try {
166-
inlinedStyles = require("!raw-loader!../public/styles.css");
167+
inlinedStyles = require(`!raw-loader!../${buildDirectory}/styles.css`);
167168
} catch (e) {
168169
console.log(e);
169170
}

examples/client-only-paths/src/html.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@ import { TypographyStyle } from "react-typography"
44
import typography from "./utils/typography"
55

66
let stylesStr
7+
const buildDirectory = process.env.GATSBY_BUILD_DIR || `public`
78
if (process.env.NODE_ENV === `production`) {
89
try {
9-
stylesStr = require(`!raw-loader!../public/styles.css`)
10+
stylesStr = require(`!raw-loader!../${buildDirectory}/styles.css`)
1011
} catch (e) {
1112
console.log(e)
1213
}

examples/using-postcss-sass/src/html.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@ import { TypographyStyle } from "react-typography"
66
const typography = new Typography()
77

88
let stylesStr
9+
const buildDirectory = process.env.GATSBY_BUILD_DIR || `public`
910
if (process.env.NODE_ENV === `production`) {
1011
try {
11-
stylesStr = require(`!raw-loader!../public/styles.css`)
12+
stylesStr = require(`!raw-loader!../${buildDirectory}/styles.css`)
1213
} catch (e) {
1314
console.log(e)
1415
}

examples/using-remark/src/html.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@ import { TypographyStyle } from "react-typography"
44
import typography from "./utils/typography"
55

66
let stylesStr
7+
const buildDirectory = process.env.GATSBY_BUILD_DIR || `public`
78
if (process.env.NODE_ENV === `production`) {
89
try {
9-
stylesStr = require(`!raw-loader!../public/styles.css`)
10+
stylesStr = require(`!raw-loader!../${buildDirectory}/styles.css`)
1011
} catch (e) {
1112
console.log(e)
1213
}

examples/using-sass/src/html.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@ import { TypographyStyle } from "react-typography"
66
const typography = new Typography()
77

88
let stylesStr
9+
const buildDirectory = process.env.GATSBY_BUILD_DIR || `public`
910
if (process.env.NODE_ENV === `production`) {
1011
try {
11-
stylesStr = require(`!raw-loader!../public/styles.css`)
12+
stylesStr = require(`!raw-loader!../${buildDirectory}/styles.css`)
1213
} catch (e) {
1314
console.log(e)
1415
}

examples/using-styled-components/src/html.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ import typography from "./utils/typography"
66
let stylesStr
77
if (process.env.NODE_ENV === `production`) {
88
try {
9-
stylesStr = require(`!raw-loader!../public/styles.css`)
9+
const buildDirectory = process.env.GATSBY_BUILD_DIR || `public`
10+
stylesStr = require(`!raw-loader!../${buildDirectory}/styles.css`)
1011
} catch (e) {
1112
console.log(e)
1213
}

examples/using-styletron/src/html.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@ import { TypographyStyle } from "react-typography"
44
import typography from "./utils/typography"
55

66
let stylesStr
7+
const buildDirectory = process.env.GATSBY_BUILD_DIR || `public`
78
if (process.env.NODE_ENV === `production`) {
89
try {
9-
stylesStr = require(`!raw-loader!../public/styles.css`)
10+
stylesStr = require(`!raw-loader!../${buildDirectory}/styles.css`)
1011
} catch (e) {
1112
console.log(e)
1213
}

examples/using-stylus/src/html.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@ import { TypographyStyle } from "react-typography"
66
const typography = new Typography()
77

88
let stylesStr
9+
const buildDirectory = process.env.GATSBY_BUILD_DIR || `public`
910
if (process.env.NODE_ENV === `production`) {
1011
try {
11-
stylesStr = require(`!raw-loader!../public/styles.css`)
12+
stylesStr = require(`!raw-loader!../${buildDirectory}/styles.css`)
1213
} catch (e) {
1314
console.log(e)
1415
}

examples/using-typescript/src/html.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@ import * as React from "react";
55

66
// Load production style
77
let styles: string;
8+
const buildDirectory = process.env.GATSBY_BUILD_DIR || `public`
89
if (process.env.NODE_ENV === `production`) {
910
try {
10-
styles = require("!raw-loader!../public/styles.css");
11+
styles = require(`!raw-loader!../${buildDirectory}/styles.css`);
1112
} catch (err) {
1213
console.log(err);
1314
}

infrastructure/build-site.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,8 @@ const Main = async () => {
142142
updateBuild(buildId, "FAILURE")
143143
process.exit(code)
144144
}
145-
const publicDir = `${pathToSite}/public`
145+
const buildDirectory = process.env.GATSBY_BUILD_DIR || `public`
146+
const publicDir = `${pathToSite}/${buildDirectory}`
146147
console.log(`uploading files from ${publicDir}`)
147148

148149
// 1. Push built files to s3 bucket

0 commit comments

Comments
 (0)