-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: adapt core plugins to gatsby hooks
- Loading branch information
1 parent
b7382aa
commit 4caa47a
Showing
13 changed files
with
119 additions
and
41 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,9 @@ | ||
import EventEmitter from 'events' | ||
|
||
import { Bundler } from '../lib/Bundler' | ||
import { Config as Args } from '../config/argv' | ||
|
||
import { server } from './server' | ||
import { build } from './build' | ||
|
||
export const emitter = new EventEmitter() | ||
export const bundler = (args: Args) => { | ||
return new Bundler({ args, build, server: server(args) }) | ||
} |
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 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 was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,7 @@ | ||
exports.createPages = require('./lib/createPages') | ||
exports.onCreateBabelConfig = require('./lib/onCreateBabelConfig') | ||
exports.onCreateDevServer = require('./lib/onCreateDevServer') | ||
exports.onCreateWebpackConfig = require('./lib/onCreateWebpackConfig') | ||
exports.onPreBuild = require('./lib/sourceNodes') | ||
exports.onPostBuild = require('./lib/sourceNodes') | ||
exports.sourceNodes = require('./lib/sourceNodes') |
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,11 +1,16 @@ | ||
const { getBaseConfig } = require('docz-core') | ||
const { Plugin, parseConfig } = require('docz-core') | ||
|
||
module.exports = async (params, opts = {}) => { | ||
const config = await parseConfig(opts) | ||
const run = Plugin.runPluginsMethod(config.plugins) | ||
|
||
module.exports = ({ actions }, opts = {}) => { | ||
const config = getBaseConfig(opts) | ||
const { paths } = config | ||
const { actions, stage } = params | ||
|
||
actions.setBabelPlugin({ | ||
name: 'babel-plugin-export-metadata', | ||
options: { root: paths.getRootDir(config) }, | ||
}) | ||
|
||
run('onCreateBabelConfig', params, stage === 'develop') | ||
} |
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,9 @@ | ||
const { Plugin, parseConfig } = require('docz-core') | ||
|
||
module.exports = async (params, opts = {}) => { | ||
const config = await parseConfig(opts) | ||
const run = Plugin.runPluginsMethod(config.plugins) | ||
const { stage } = params | ||
|
||
run('onCreateDevServer', params, stage === 'develop') | ||
} |
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,24 @@ | ||
const fs = require('fs-extra') | ||
const path = require('path') | ||
const { Plugin, parseConfig } = require('docz-core') | ||
|
||
const nodeModules = path.resolve(__dirname, 'node_modules') | ||
const parentNodeModules = path.resolve(__dirname, '../../../node_modules') | ||
|
||
module.exports = async (params, opts) => { | ||
const { stage, actions, getConfig } = params | ||
const hasParentNodeModules = fs.pathExistsSync(parentNodeModules) | ||
const args = await parseConfig(opts) | ||
const run = Plugin.runPluginsMethod(args.plugins) | ||
const config = getConfig() | ||
|
||
if (hasParentNodeModules && stage === 'develop') { | ||
actions.setWebpackConfig({ | ||
resolve: { | ||
modules: [nodeModules, parentNodeModules], | ||
}, | ||
}) | ||
} | ||
|
||
run('onCreateWebpack', config, stage === 'develop', args) | ||
} |
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,6 @@ | ||
const { Plugin, parseConfig } = require('docz-core') | ||
|
||
module.exports = async (params, opts = {}) => { | ||
const config = await parseConfig(opts) | ||
Plugin.runPluginsMethod(config.plugins)('onPreBuild') | ||
} |
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,6 @@ | ||
const { Plugin, parseConfig } = require('docz-core') | ||
|
||
module.exports = async (params, opts = {}) => { | ||
const config = await parseConfig(opts) | ||
Plugin.runPluginsMethod(config.plugins)('onPreBuild') | ||
} |