Skip to content
This repository has been archived by the owner on Jan 2, 2024. It is now read-only.

Commit

Permalink
Adds lodash library and babel plugin.
Browse files Browse the repository at this point in the history
  • Loading branch information
Vagr9K committed Jul 7, 2017
1 parent 1932cf7 commit 428dccd
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 2 deletions.
3 changes: 3 additions & 0 deletions .babelrc
@@ -0,0 +1,3 @@
{
"plugins": ["lodash"]
}
15 changes: 13 additions & 2 deletions gatsby-node.js
@@ -1,4 +1,5 @@
const path = require('path');
const webpackLodashPlugin = require('lodash-webpack-plugin');

exports.onCreateNode = ({ node, boundActionCreators, getNode }) => {
const { createNodeField } = boundActionCreators;
Expand All @@ -22,14 +23,17 @@ exports.createPages = ({ graphql, boundActionCreators }) => {
const { createPage } = boundActionCreators;

return new Promise((resolve, reject) => {
const blogPost = path.resolve('src/templates/post.jsx');
const postPage = path.resolve('src/templates/post.jsx');
resolve(
graphql(
`
{
allMarkdownRemark {
edges {
node {
frontmatter {
tags
}
fields {
slug
}
Expand All @@ -48,7 +52,7 @@ exports.createPages = ({ graphql, boundActionCreators }) => {
result.data.allMarkdownRemark.edges.forEach((edge) => {
createPage({
path: edge.node.fields.slug,
component: blogPost,
component: postPage,
context: {
slug: edge.node.fields.slug,
},
Expand All @@ -58,3 +62,10 @@ exports.createPages = ({ graphql, boundActionCreators }) => {
);
});
};

exports.modifyWebpackConfig = ({ config, stage }) => {
if (stage === 'build-javascript') {
config.plugin('Lodash', webpackLodashPlugin, null);
}
}
;
3 changes: 3 additions & 0 deletions package.json
Expand Up @@ -4,6 +4,7 @@
"version": "0.1.7",
"author": "Ruben Harutyunyan",
"dependencies": {
"babel-plugin-lodash": "^3.2.11",
"font-awesome": "^4.7.0",
"gatsby": "^1.0.2",
"gatsby-link": "^1.0.1",
Expand All @@ -19,6 +20,8 @@
"gatsby-remark-smartypants": "^1.0.1",
"gatsby-source-filesystem": "^1.0.1",
"gatsby-transformer-remark": "^1.0.1",
"lodash": "^4.17.4",
"lodash-webpack-plugin": "^0.11.4",
"react-disqus-comments": "^1.0.3",
"react-md": "^1.1.0-alpha-5"
},
Expand Down
13 changes: 13 additions & 0 deletions yarn.lock
Expand Up @@ -559,6 +559,13 @@ babel-plugin-check-es2015-constants@^6.22.0:
dependencies:
babel-runtime "^6.22.0"

babel-plugin-lodash@^3.2.11:
version "3.2.11"
resolved "https://registry.yarnpkg.com/babel-plugin-lodash/-/babel-plugin-lodash-3.2.11.tgz#21c8fdec9fe1835efaa737873e3902bdd66d5701"
dependencies:
glob "^7.1.1"
lodash "^4.17.2"

babel-plugin-syntax-async-functions@^6.8.0:
version "6.13.0"
resolved "https://registry.yarnpkg.com/babel-plugin-syntax-async-functions/-/babel-plugin-syntax-async-functions-6.13.0.tgz#cad9cad1191b5ad634bf30ae0872391e0647be95"
Expand Down Expand Up @@ -5096,6 +5103,12 @@ lodash-id@^0.14.0:
version "0.14.0"
resolved "https://registry.yarnpkg.com/lodash-id/-/lodash-id-0.14.0.tgz#baf48934e543a1b5d6346f8c84698b1a8c803896"

lodash-webpack-plugin@^0.11.4:
version "0.11.4"
resolved "https://registry.yarnpkg.com/lodash-webpack-plugin/-/lodash-webpack-plugin-0.11.4.tgz#6c3ecba3d4b8d24b53940b63542715c5ed3c4ac5"
dependencies:
lodash "^4.17.4"

lodash._basecopy@^3.0.0:
version "3.0.1"
resolved "https://registry.yarnpkg.com/lodash._basecopy/-/lodash._basecopy-3.0.1.tgz#8da0e6a876cf344c0ad8a54882111dd3c5c7ca36"
Expand Down

0 comments on commit 428dccd

Please sign in to comment.