Skip to content

Commit

Permalink
Add assetPrefix
Browse files Browse the repository at this point in the history
- Only when not on latest version
- Remove `move-built-files` script
  • Loading branch information
kylegach committed Nov 5, 2021
1 parent 0e97a62 commit 2f4706d
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 25 deletions.
7 changes: 7 additions & 0 deletions gatsby-config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const path = require('path');
const { global } = require('@storybook/design-system');
const siteMetadata = require('./site-metadata');
const getReleaseBranch = require('./src/util/get-release-branch');

require('dotenv').config({
path: `.env.${process.env.NODE_ENV}`,
Expand All @@ -14,7 +15,13 @@ module.exports = {
PRESERVE_WEBPACK_CACHE: true,
FAST_DEV: true,
QUERY_ON_DEMAND: true,
...(!isLatest && {
PREFIX_PATHS: true,
}),
},
...(!isLatest && {
assetPrefix: getReleaseBranch(versionString),
}),
plugins: [
'gatsby-plugin-react-helmet',
'gatsby-plugin-typescript',
Expand Down
3 changes: 1 addition & 2 deletions gatsby-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const { toc: docsToc } = require('./src/content/docs/toc');
const addStateToToc = require('./src/util/add-state-to-toc');
const buildPathWithFramework = require('./src/util/build-path-with-framework');
const createAddonsPages = require('./src/util/create-addons-pages');
const getReleaseBranch = require('./src/util/get-release-branch');

const VERSION_PARTS_REGEX = /^(\d+\.\d+)(?:\.\d+)?-?(\w+)?(?:\.\d+$)?/;

Expand Down Expand Up @@ -284,8 +285,6 @@ exports.createPages = ({ actions, graphql }) => {
});
};

const getReleaseBranch = (version) => `release-${version.replace('.', '-')}`;

function getVersionData(distTag) {
const versionFile = `./src/content/docs/versions/${distTag}.json`;
if (!fs.existsSync(versionFile)) {
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@
"extract-monorepo-docs": "./scripts/extract-monorepo-docs.sh",
"prebuild": "yarn extract-monorepo-docs",
"build": "gatsby build",
"postbuild": "./scripts/move-built-files.sh",
"serve": "gatsby serve",
"develop": "gatsby develop",
"clean": "gatsby clean",
Expand Down
22 changes: 0 additions & 22 deletions scripts/move-built-files.sh

This file was deleted.

3 changes: 3 additions & 0 deletions src/util/get-release-branch.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = function getReleaseBranch(version) {
return `release-${version.replace('.', '-')}`;
};

0 comments on commit 2f4706d

Please sign in to comment.