Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion lib/utils/babel-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import fs from 'fs'
import path from 'path'
import json5 from 'json5'
import startsWith from 'lodash/startsWith'
import objectAssign from 'object-assign'
import invariant from 'invariant'

const DEFAULT_BABEL_CONFIG = {
Expand Down Expand Up @@ -65,7 +66,7 @@ function normalizeConfig (config, directory) {
normalizedConfig.plugins.push(resolvePlugin(plugin, directory, 'plugin'))
})

return normalizedConfig
return objectAssign({}, config, normalizedConfig)
}

/**
Expand Down Expand Up @@ -118,5 +119,9 @@ export default function babelConfig (program, stage) {
babelrc.presets.unshift('react-hmre')
}

if (!babelrc.hasOwnProperty('cacheDirectory')) {
babelrc.cacheDirectory = true
}

return normalizeConfig(babelrc, directory)
}
23 changes: 18 additions & 5 deletions lib/utils/glob-pages.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ import glob from 'glob'
import buildPage from './build-page'
const debug = require('debug')('gatsby:glob')

module.exports = (directory, callback) => {
const pagesData = []

function globQuery (directory) {
// Make this list easy to modify through the config?
// Or just keep adding extensions...?
const fileTypesToGlob = [
Expand All @@ -20,15 +18,30 @@ module.exports = (directory, callback) => {
]
const fileGlobQuery = fileTypesToGlob.map((type) => `*.${type}`)
const joinedFileQuery = fileGlobQuery.join('|')
const globQuery = `${directory}/pages/**/?(${joinedFileQuery})`
glob(globQuery, null, (err, pages) => {
return `${directory}/pages/**/?(${joinedFileQuery})`
}

let globCache
function createCache (directory, callback) {
const pagesData = []

glob(globQuery(directory), null, (err, pages) => {
if (err) { return callback(err) }

pages.forEach((page) => {
pagesData.push(buildPage(directory, page))
})

debug(`globbed ${pagesData.length} pages`)
globCache = pagesData
return callback(null, pagesData)
})
}

module.exports = function globPages (directory, callback) {
if (typeof globCache === 'undefined') {
createCache(directory, callback)
} else {
callback(null, globCache)
}
}
15 changes: 7 additions & 8 deletions lib/utils/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,11 +154,9 @@ module.exports = (program, directory, stage, webpackPort = 1500, routes = []) =>
'.toml',
'.yaml',
],
modulesDirectories: [
root: [
directory,
`${__dirname}/../isomorphic`,
`${directory}/node_modules`,
'node_modules',
path.resolve(__dirname, '..', 'isomorphic'),
],
}
}
Expand Down Expand Up @@ -365,11 +363,12 @@ module.exports = (program, directory, stage, webpackPort = 1500, routes = []) =>
devtool: devtool(),
output: output(),
resolveLoader: {
root: [
path.resolve(directory, 'loaders'),
path.resolve(__dirname, '..', 'loaders'),
],
modulesDirectories: [
`${directory}/node_modules`,
`${directory}/loaders`,
`${__dirname}/../../node_modules`,
`${__dirname}/../loaders`,
'node_modules',
],
},
plugins: plugins(),
Expand Down