Skip to content

Commit f382919

Browse files
authored
fix: build script to run using gatsby-cli v1.12 (fix #9) (#11)
1 parent a0dc172 commit f382919

File tree

5 files changed

+3676
-1235
lines changed

5 files changed

+3676
-1235
lines changed

bin/build.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,8 +175,8 @@ function build() {
175175
} else if (isServe) {
176176
cmd = `npm run clean && npm run build && npm run serve`;
177177
} else {
178-
cmd = `npm run clean && npm run build:prefix latest && cp -r public ${latestDir} && `;
179-
cmd += `npm run clean && npm run build:prefix && cp -r public ${versionDir}`;
178+
cmd = `npm run clean && npm run build:latest && cp -r public ${latestDir} && `;
179+
cmd += `npm run clean && npm run build:semver && cp -r public ${versionDir}`;
180180
}
181181

182182
process.chdir(path.resolve(__dirname, '../')); // change working directory

gatsby-config.js

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,23 @@
11
const path = require('path');
22
const options = require(path.resolve(process.cwd(), 'src/data/layout.json'));
33

4-
const [{ header, pathPrefix }] = options;
5-
const { version } = header;
4+
const activeEnv = process.env.GATSBY_ACTIVE_ENV;
5+
let pathPrefix;
66

7-
const isLatest = process.argv.indexOf('latest') > -1;
8-
const folderName = isLatest ? 'latest' : version;
7+
if (activeEnv) {
8+
const [
9+
{
10+
header: { version },
11+
pathPrefix: optPathPrefix
12+
}
13+
] = options;
14+
const folderName = activeEnv.indexOf('latest') > -1 ? 'latest' : version;
15+
16+
pathPrefix = `/${optPathPrefix}/${folderName}`;
17+
}
918

1019
module.exports = {
11-
pathPrefix: `/${pathPrefix}/${folderName}`,
20+
pathPrefix,
1221
plugins: [
1322
`gatsby-plugin-sass`,
1423
{

gatsby-node.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ exports.createPages = ({ graphql, actions }) => {
4747
// Data passed to context is available
4848
// in page queries as GraphQL variables.
4949
id: pid,
50-
filename: filename
50+
filename
5151
}
5252
});
5353
});

0 commit comments

Comments
 (0)