Skip to content
This repository has been archived by the owner on Jul 16, 2023. It is now read-only.

Commit

Permalink
feat(config): use generate config.js imported by frontend code
Browse files Browse the repository at this point in the history
  • Loading branch information
filipowm committed Jun 3, 2020
1 parent bed1bbb commit 1888270
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ node_modules
.vscode/
*.iml
reduxcache*
*.log
*.log
.generated.config.js
10 changes: 10 additions & 0 deletions config/config-js-writer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
const fs = require('fs');

const generate = (path, config) => {
const generated = `module.exports = ${JSON.stringify(config, undefined, 4)};`;
fs.writeFile(path, generated, function (err) {
if (err) return console.log(err);
});
}

module.exports = generate;
5 changes: 4 additions & 1 deletion gatsby-config.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
// 08:46
require("dotenv").config();
const queries = require("./src/utils/algolia");
const readConfig = require("./config/config-reader")
const writeConfig = require("./config/config-js-writer")
const path = require('path');
const globImporter = require('node-sass-glob-importer');

const config = readConfig();
writeConfig(__dirname + "/.generated.config.js", config);

const plugins = [
'gatsby-plugin-sitemap',
Expand Down Expand Up @@ -91,7 +94,7 @@ const plugins = [
resolve: 'gatsby-plugin-root-import',
options: {
"~": path.join(__dirname, 'src'),
config: path.join(__dirname, 'config/config.js'),
config: path.join(__dirname, '.generated.config.js'),
images: path.join(__dirname, 'src/images'),
styles: path.join(__dirname, 'src/styles'),
css: path.join(__dirname, 'src/styles/main.scss')
Expand Down

0 comments on commit 1888270

Please sign in to comment.