-
-
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(docz-core): improve plugin and add support to modify babel
- Loading branch information
1 parent
2bd3b5b
commit cf3ec4e
Showing
11 changed files
with
131 additions
and
70 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,31 @@ | ||
import * as fs from 'fs-extra' | ||
import logger from 'signale' | ||
|
||
import * as paths from '../config/paths' | ||
import { loadConfig } from '../utils/load-config' | ||
import { webpack } from '../bundlers' | ||
import { Entries } from '../Entries' | ||
import { Config } from './args' | ||
import { Plugin } from '../Plugin' | ||
|
||
export const build = async (args: Config) => { | ||
const config = loadConfig(args) | ||
const bundler = webpack(config, 'production') | ||
const entries = new Entries(config) | ||
const map = await entries.getMap() | ||
const run = Plugin.runPluginsMethod(config.plugins) | ||
|
||
await fs.remove(paths.app) | ||
await Entries.writeApp(config) | ||
await Entries.writeImports(map) | ||
await Entries.writeData(map, config) | ||
|
||
await bundler.build() | ||
try { | ||
await run('onPreBuild') | ||
await bundler.build(bundler.getConfig()) | ||
await run('onPostBuild') | ||
} catch (err) { | ||
logger.fatal(err) | ||
process.exit(1) | ||
} | ||
} |
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,22 @@ | ||
import { load } from 'load-cfg' | ||
import merge from 'deepmerge' | ||
|
||
import { Config } from '../commands/args' | ||
import { isFn } from './helpers' | ||
|
||
export const babelrc = (args: Config) => { | ||
const config = merge(load('babel', null), { | ||
babelrc: false, | ||
cacheDirectory: !args.debug, | ||
presets: [require.resolve('babel-preset-react-app')], | ||
plugins: [], | ||
}) | ||
|
||
return [...(args.plugins || [])].reduce( | ||
(obj, plugin) => | ||
isFn(plugin.modifyBabelRc) | ||
? merge(obj, plugin.modifyBabelRc(config)) | ||
: obj, | ||
config | ||
) | ||
} |
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