diff --git a/.gitignore b/.gitignore index d7d47e15..110eb6a7 100755 --- a/.gitignore +++ b/.gitignore @@ -8,4 +8,5 @@ node_modules .vscode/ *.iml reduxcache* -*.log \ No newline at end of file +*.log +.generated.config.js \ No newline at end of file diff --git a/config/config-js-writer.js b/config/config-js-writer.js new file mode 100644 index 00000000..06758eec --- /dev/null +++ b/config/config-js-writer.js @@ -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; \ No newline at end of file diff --git a/gatsby-config.js b/gatsby-config.js index 9ab193c5..a752a693 100755 --- a/gatsby-config.js +++ b/gatsby-config.js @@ -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', @@ -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')