-
Notifications
You must be signed in to change notification settings - Fork 10.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Don't use app.js. Move its functionality to webpack.config.js
app.js had three weirdly merged features. 1. It held the require.context magic function stuff from Webpack to autoload page modules from the `pages` directory. 2. You could export a function to programatically rewrite paths. 3. You could export a function which would get run on every route change (useful for things like tracking path changes in Google Analytics). This PR moves the require.context to a an auto-written file. This sets the stage for #208. To rewrite paths, now export the same function from gatsby.config.js. And for `onRouteChange`, export this from `gatsby-client-utils.js` which is for client-only user functions used by Gatsby core.
- Loading branch information
1 parent
b3841e9
commit 1055368
Showing
12 changed files
with
50 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,11 @@ | ||
import webpack from 'webpack' | ||
import webpackConfig from './webpack.config' | ||
import getUserGatsbyConfig from './get-user-gatsby-config' | ||
|
||
module.exports = (program, callback) => { | ||
const { directory } = program | ||
|
||
// Build production js. | ||
const compilerConfig = webpackConfig(program, directory, 'production') | ||
const config = getUserGatsbyConfig(compilerConfig, 'production') | ||
|
||
return webpack(config.resolve()).run((err, stats) => callback(err, stats)) | ||
return webpack(compilerConfig.resolve()).run((err, stats) => callback(err, stats)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
// This file is auto-written and used by Gatsby to require | ||
// files from your pages directory. | ||
module.exports = function (callback) { | ||
let context = require.context('./pages', true) | ||
if (module.hot) { | ||
module.hot.accept(context.id, () => { | ||
context = require.context('./pages', true) | ||
return callback(context) | ||
}) | ||
} | ||
return callback(context) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters