Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 44f451e

Browse files
graceparkmikesurowiec
andauthoredJul 22, 2021
Removing webpack build step (github#20405)
* removing webpack build step * keep copywebpackplugin and add fonts to assets/fonts * update marketing font path * update font path * update font * remove builtAssets * remove copying front end code with dist * move Inter fonts to /assets/fonts/inter * move copy-webpack-plugin back to deps Co-authored-by: Mike Surowiec <[email protected]>
1 parent 3db2e89 commit 44f451e

File tree

11 files changed

+251
-643
lines changed

11 files changed

+251
-643
lines changed
 

‎.gitignore

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,13 @@ npm-debug.log
77
coverage/
88
.linkinator
99
/assets/images/early-access
10+
/assets/fonts/inter
1011
/content/early-access
1112
/data/early-access
12-
dist
1313
.next
1414
.eslintcache
1515

1616
# blc: broken link checker
1717
blc_output.log
1818
blc_output_internal.log
19-
/dist/
2019
broken_links.md

‎Dockerfile

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ COPY lib ./lib
4646
# one part of the build relies on this content file to pull all-products
4747
COPY content/index.md ./content/index.md
4848

49-
COPY webpack.config.js ./webpack.config.js
5049
COPY next.config.js ./next.config.js
5150
COPY tsconfig.json ./tsconfig.json
5251

@@ -73,7 +72,6 @@ USER node
7372
COPY --chown=node:node --from=prod_deps /usr/src/docs/node_modules /usr/src/docs/node_modules
7473

7574
# Copy our front-end code
76-
COPY --chown=node:node --from=builder /usr/src/docs/dist /usr/src/docs/dist
7775
COPY --chown=node:node --from=builder /usr/src/docs/.next /usr/src/docs/.next
7876

7977
# We should always be running in production mode

‎lib/built-asset-urls.js

Lines changed: 0 additions & 23 deletions
This file was deleted.

‎middleware/context.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import xPathUtils from '../lib/path-utils.js'
66
import productNames from '../lib/product-names.js'
77
import warmServer from '../lib/warm-server.js'
88
import readJsonFile from '../lib/read-json-file.js'
9-
import builtAssets from '../lib/built-asset-urls.js'
109
import searchVersions from '../lib/search/versions.js'
1110
import nonEnterpriseDefaultVersion from '../lib/non-enterprise-default-version.js'
1211
const activeProducts = Object.values(productMap).filter(
@@ -58,9 +57,6 @@ export default async function contextualize(req, res, next) {
5857
req.context.siteTree = siteTree
5958
req.context.pages = pageMap
6059

61-
// JS + CSS asset paths
62-
req.context.builtAssets = builtAssets
63-
6460
// Object exposing selected variables to client
6561
req.context.expose = JSON.stringify({
6662
// Languages and versions for search

‎middleware/handle-errors.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import FailBot from '../lib/failbot.js'
22
import loadSiteData from '../lib/site-data.js'
3-
import builtAssets from '../lib/built-asset-urls.js'
43
import { nextApp } from './next.js'
54

65
function shouldLogException(error) {
@@ -42,9 +41,8 @@ export default async function handleError(error, req, res, next) {
4241
// set req.context.site here so we can pass data/ui.yml text to the 500 layout
4342
if (!req.context) {
4443
const site = await loadSiteData()
45-
req.context = { site: site[req.language || 'en'].site, builtAssets }
44+
req.context = { site: site[req.language || 'en'].site }
4645
}
47-
4846
// display error on the page in development and staging, but not in production
4947
if (req.context && process.env.HEROKU_PRODUCTION_APP !== 'true') {
5048
req.context.error = error

‎next.config.js

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,30 @@
33

44
const fs = require('fs')
55
const frontmatter = require('gray-matter')
6+
const CopyWebpackPlugin = require('copy-webpack-plugin')
67
const path = require('path')
78
const homepage = path.posix.join(process.cwd(), 'content/index.md')
89
const { data } = frontmatter(fs.readFileSync(homepage, 'utf8'))
910
const productIds = data.children
1011

1112
module.exports = {
13+
webpack: (config, { isServer }) => {
14+
if (isServer) {
15+
config.plugins.push(
16+
new CopyWebpackPlugin({
17+
patterns: [
18+
{
19+
from: path.join(__dirname, 'node_modules/@primer/css/fonts'),
20+
to: path.join(__dirname, 'assets/fonts/inter'),
21+
},
22+
],
23+
})
24+
)
25+
}
26+
return config
27+
},
1228
// speed up production `next build` by ignoring typechecking during that step of build.
1329
// type-checking still occurs in the Dockerfile build
14-
future: {
15-
webpack: 5,
16-
},
1730
typescript: {
1831
ignoreBuildErrors: true,
1932
},

0 commit comments

Comments
 (0)
Please sign in to comment.