Skip to content

Commit

Permalink
Merge branch 'master' into revert-3600-feature/filter-linked-node
Browse files Browse the repository at this point in the history
  • Loading branch information
KyleAMathews authored Jan 19, 2018
2 parents fdf16dd + 01022ab commit ee468f2
Show file tree
Hide file tree
Showing 5 changed files with 81 additions and 40 deletions.
2 changes: 1 addition & 1 deletion packages/gatsby-plugin-create-client-paths/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "gatsby-plugin-create-client-paths",
"version": "1.0.2",
"version": "1.0.3",
"description": "Gatsby-plugin for creating paths that exist only on the client",
"main": "index.js",
"scripts": {
Expand Down
80 changes: 58 additions & 22 deletions packages/gatsby-plugin-netlify-cms/src/gatsby-node.js
Original file line number Diff line number Diff line change
@@ -1,34 +1,70 @@
const HtmlWebpackPlugin = require(`html-webpack-plugin`)
const HtmlWebpackIncludeAssetsPlugin = require(`html-webpack-include-assets-plugin`)
const ExtractTextPlugin = require(`extract-text-webpack-plugin`)

function plugins(stage) {
const commonPlugins = [
// Output /admin/index.html
new HtmlWebpackPlugin({
title: `Content Manager`,
filename: `admin/index.html`,
chunks: [`cms`],
}),

// Include the identity widget script in the html file
new HtmlWebpackIncludeAssetsPlugin({
assets: [`https://identity.netlify.com/v1/netlify-identity-widget.js`],
append: false,
publicPath: false,
}),
]

exports.modifyWebpackConfig = (
{ config, stage },
{ modulePath = `${__dirname}/cms.js` }
) => {
switch (stage) {
case `develop`:
return commonPlugins
case `build-javascript`:
return [...commonPlugins, new ExtractTextPlugin(`cms.css`)]
default:
return []
}
}

function module(config, stage) {
switch (stage) {
case `build-javascript`:
config.merge({
entry: {
cms: modulePath,
},
plugins: [
new HtmlWebpackPlugin({
title: `Content Manager`,
filename: `admin/index.html`,
chunks: [`cms`],
}),
new HtmlWebpackIncludeAssetsPlugin({
assets: [
`https://identity.netlify.com/v1/netlify-identity-widget.js`,
],
append: false,
publicPath: false,
}),
],
// Exclude Netlify CMS styles from Gatsby CSS bundle. This relies on
// Gatsby using webpack-configurator for webpack config extension, and
// also on the target loader key being named "css" in Gatsby's webpack
// config.
config.loader(`css`, {
exclude: [/\/node_modules\/netlify-cms\//],
})

// Exclusively extract Netlify CMS styles to /cms.css (filename configured
// above with plugin instantiation).
config.loader(`cms-css`, {
test: /\.css$/,
include: [/\/node_modules\/netlify-cms\//],
loader: ExtractTextPlugin.extract([`css`]),
})
return config
default:
return config
}
}

exports.modifyWebpackConfig = (
{ config, stage },
{ modulePath = `${__dirname}/cms.js` }
) => {
config.merge({
entry: {
cms: modulePath,
},
plugins: plugins(stage),
})

module(config, stage)

return config
}
27 changes: 16 additions & 11 deletions packages/gatsby-remark-images/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,14 +141,16 @@ module.exports = (
fileType !== `svg`
) {
const rawHTML = await generateImagesAndUpdateNode(node, resolve)
// Replace the image node with an inline HTML node.
node.type = `html`
node.value = rawHTML
return resolve(node)
} else {
// Image isn't relative so there's nothing for us to do.
return resolve()

if (rawHTML != null) {
// Replace the image node with an inline HTML node.
node.type = `html`
node.value = rawHTML
}
}

// Image isn't relative so there's nothing for us to do.
return resolve()
})
)
).then(markdownImageNodes =>
Expand Down Expand Up @@ -197,11 +199,14 @@ module.exports = (
formattedImgTag,
resolve
)
// Replace the image string
thisImg.replaceWith(rawHTML)
} else {
return resolve()

if (rawHTML != null) {
// Replace the image string
thisImg.replaceWith(rawHTML)
}
}

return resolve()
}

// Replace the image node with an inline HTML node.
Expand Down
2 changes: 1 addition & 1 deletion packages/gatsby/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "gatsby",
"description": "React.js Static Site Generator",
"version": "1.9.160",
"version": "1.9.161",
"author": "Kyle Mathews <mathews.kyle@gmail.com>",
"bin": {
"gatsby": "./dist/bin/gatsby.js"
Expand Down
10 changes: 5 additions & 5 deletions packages/gatsby/src/utils/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ module.exports = async (
// Common config for every env.
config.loader(`js`, {
test: /\.jsx?$/, // Accept either .js or .jsx files.
exclude: /(node_modules|bower_components)/,
exclude: [/(node_modules|bower_components)/],
loader: `babel`,
query: babelConfig,
})
Expand Down Expand Up @@ -409,7 +409,7 @@ module.exports = async (
case `develop`:
config.loader(`css`, {
test: /\.css$/,
exclude: /\.module\.css$/,
exclude: [/\.module\.css$/],
loaders: [`style`, `css`, `postcss`],
})

Expand All @@ -434,7 +434,7 @@ module.exports = async (
case `build-css`:
config.loader(`css`, {
test: /\.css$/,
exclude: /\.module\.css$/,
exclude: [/\.module\.css$/],
loader: ExtractTextPlugin.extract([`css?minimize`, `postcss`]),
})

Expand Down Expand Up @@ -464,7 +464,7 @@ module.exports = async (

config.loader(`css`, {
test: /\.css$/,
exclude: /\.module\.css$/,
exclude: [/\.module\.css$/],
loader: `null`,
})

Expand All @@ -489,7 +489,7 @@ module.exports = async (

config.loader(`css`, {
test: /\.css$/,
exclude: /\.module\.css$/,
exclude: [/\.module\.css$/],
// loader: `null`,
loader: ExtractTextPlugin.extract([`css`]),
})
Expand Down

0 comments on commit ee468f2

Please sign in to comment.