Skip to content

Commit

Permalink
fix: build script to run using gatsby-cli v1.12 (fix #9) (#11)
Browse files Browse the repository at this point in the history
  • Loading branch information
seonim-ryu authored Jun 11, 2020
1 parent a0dc172 commit f382919
Show file tree
Hide file tree
Showing 5 changed files with 3,676 additions and 1,235 deletions.
4 changes: 2 additions & 2 deletions bin/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,8 @@ function build() {
} else if (isServe) {
cmd = `npm run clean && npm run build && npm run serve`;
} else {
cmd = `npm run clean && npm run build:prefix latest && cp -r public ${latestDir} && `;
cmd += `npm run clean && npm run build:prefix && cp -r public ${versionDir}`;
cmd = `npm run clean && npm run build:latest && cp -r public ${latestDir} && `;
cmd += `npm run clean && npm run build:semver && cp -r public ${versionDir}`;
}

process.chdir(path.resolve(__dirname, '../')); // change working directory
Expand Down
19 changes: 14 additions & 5 deletions gatsby-config.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,23 @@
const path = require('path');
const options = require(path.resolve(process.cwd(), 'src/data/layout.json'));

const [{ header, pathPrefix }] = options;
const { version } = header;
const activeEnv = process.env.GATSBY_ACTIVE_ENV;
let pathPrefix;

const isLatest = process.argv.indexOf('latest') > -1;
const folderName = isLatest ? 'latest' : version;
if (activeEnv) {
const [
{
header: { version },
pathPrefix: optPathPrefix
}
] = options;
const folderName = activeEnv.indexOf('latest') > -1 ? 'latest' : version;

pathPrefix = `/${optPathPrefix}/${folderName}`;
}

module.exports = {
pathPrefix: `/${pathPrefix}/${folderName}`,
pathPrefix,
plugins: [
`gatsby-plugin-sass`,
{
Expand Down
2 changes: 1 addition & 1 deletion gatsby-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ exports.createPages = ({ graphql, actions }) => {
// Data passed to context is available
// in page queries as GraphQL variables.
id: pid,
filename: filename
filename
}
});
});
Expand Down
Loading

0 comments on commit f382919

Please sign in to comment.