Skip to content

Commit

Permalink
Add new Gatsby plugin for Lodash which adds their webpack & babel plu…
Browse files Browse the repository at this point in the history
…gins to builds. (gatsbyjs#2162)

* Add gatsby-plugin-lodash

* Make new packages default to 1.0.0

* Publish

 - [email protected]
  • Loading branch information
KyleAMathews authored Sep 18, 2017
1 parent ed945ae commit ce58928
Show file tree
Hide file tree
Showing 10 changed files with 103 additions and 1 deletion.
3 changes: 3 additions & 0 deletions packages/gatsby-plugin-lodash/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/*.js
!index.js
yarn.lock
34 changes: 34 additions & 0 deletions packages/gatsby-plugin-lodash/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Logs
logs
*.log

# Runtime data
pids
*.pid
*.seed

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage

# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# node-waf configuration
.lock-wscript

# Compiled binary addons (http://nodejs.org/api/addons.html)
build/Release

# Dependency directory
# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git
node_modules
*.un~
yarn.lock
src
flow-typed
coverage
decls
examples
18 changes: 18 additions & 0 deletions packages/gatsby-plugin-lodash/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# gatsby-plugin-lodash

Adds the Lodash webpack & Babel plugins for easy modular, small Lodash builds.

## Install

`npm install --save gatsby-plugin-lodash`

## How to use

Simply add the plugin to your `gatsby-config.js`.

```javascript
plugins: [
`gatsby-plugin-lodash`,
]
```

1 change: 1 addition & 0 deletions packages/gatsby-plugin-lodash/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
// noop
26 changes: 26 additions & 0 deletions packages/gatsby-plugin-lodash/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"name": "gatsby-plugin-lodash",
"version": "1.0.1",
"description": "Easy modular Lodash builds. Adds the Lodash webpack & Babel plugins to your Gatsby build",
"main": "index.js",
"scripts": {
"build": "babel src --out-dir . --ignore __tests__",
"watch": "babel -w src --out-dir . --ignore __tests__",
"prepublish": "cross-env NODE_ENV=production npm run build"
},
"keywords": [
"gatsby"
],
"author": "Kyle Mathews <[email protected]>",
"license": "MIT",
"dependencies": {
"babel-plugin-lodash": "^3.2.11",
"babel-runtime": "^6.26.0",
"lodash": "^4.17.4",
"lodash-webpack-plugin": "^0.11.4"
},
"devDependencies": {
"babel-cli": "^6.26.0",
"cross-env": "^5.0.5"
}
}
Empty file.
18 changes: 18 additions & 0 deletions packages/gatsby-plugin-lodash/src/gatsby-node.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
const webpackLodashPlugin = require(`lodash-webpack-plugin`)

// Add Lodash webpack plugin
exports.modifyWebpackConfig = ({ config, stage }) => {
if (stage === `build-javascript`) {
config.plugin(`Lodash`, webpackLodashPlugin, null)
}

return
}

// Add Lodash Babel plugin
exports.modifyBabelrc = ({ babelrc }) => {
return {
...babelrc,
plugins: babelrc.plugins.concat([`lodash`]),
}
}
2 changes: 1 addition & 1 deletion plop-templates/package/package.json.hbs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "{{kebabCase name}}",
"version": "",
"version": "1.0.0",
"description": "Stub description for {{name}}",
"main": "index.js",
"scripts": {
Expand Down
1 change: 1 addition & 0 deletions www/gatsby-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ module.exports = {
`gatsby-plugin-sharp`,
`gatsby-plugin-catch-links`,
`gatsby-plugin-react-next`,
`gatsby-plugin-lodash`,
{
resolve: `gatsby-plugin-manifest`,
options: {
Expand Down
1 change: 1 addition & 0 deletions www/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"gatsby-plugin-feed": "^1.3.9",
"gatsby-plugin-glamor": "^1.6.7",
"gatsby-plugin-google-analytics": "^1.0.7",
"gatsby-plugin-lodash": "^1.0.0",
"gatsby-plugin-manifest": "^1.0.7",
"gatsby-plugin-nprogress": "^1.0.7",
"gatsby-plugin-offline": "^1.0.9",
Expand Down

0 comments on commit ce58928

Please sign in to comment.