Skip to content

Commit

Permalink
[feat] open doraPlugins to specify, close #28 (#31)
Browse files Browse the repository at this point in the history
* [feat] open doraPlugins to specify, close #28

* [fix] use compiler before all plugins
  • Loading branch information
jaredleechn authored Aug 25, 2016
1 parent c9162f0 commit d787e67
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 13 deletions.
21 changes: 11 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,16 +70,17 @@ $ npm i atool-doc -g

atool-doc [options]

-h, --help output usage information
-v, --version output the version number
--dest <dir> config path of output dir, default __site
--source <dir> config path of demo files dir, default examples
--asset <dir> config path of static resource, default statics
--tpl <path> config path or name of tpl file
--config <path> config path of webpack.config, default webpack.config.js
--port <number> specify server port, default 8002
--build only build
-w, --watch using with --build, watch mode
-h, --help output usage information
-v, --version output the version number
--dest <dir> config path of output dir, default __site
--source <dir> config path of demo files dir, default examples
--asset <dir> config path of static resource, default statics
--tpl <path> config path or name of tpl file
--config <path> config path of webpack.config, default webpack.config.js
--port <number> specify dora server port, default 8002
--doraPlugins <name|file> defines the plugins which should used with dora server, default proxy
--build only build
-w, --watch using with --build, watch mode
```

## How to write demo file
Expand Down
3 changes: 2 additions & 1 deletion bin/atool-doc.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ if (!process.send) {
.option('--asset <dir>', 'config path of static resource, default statics', 'statics')
.option('--tpl <path>', 'config path or name of tpl file')
.option('--config <path>', 'config path of webpack.config, default webpack.config.js', 'webpack.config.js')
.option('--port <number>', 'specify server port, default 8002', '8002')
.option('--port <number>', 'specify dora server port, default 8002', '8002')
.option('--doraPlugins <name|file>', 'defines the plugins which should used with dora server, default proxy', 'proxy')
.option('--build', 'only build')
.option('-w, --watch', 'using with --build, watch mode')
.parse(process.argv);
Expand Down
9 changes: 7 additions & 2 deletions src/doc.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,12 @@ import chokidar from 'chokidar';
const root = join(__dirname, '..');

export default function (options) {
const { source, dest, cwd, tpl, config, port, asset } = options;
const { source, dest, cwd, tpl, config, port, asset, doraPlugins } = options;

const plugins = doraPlugins ? doraPlugins.split(',') : [];
if (plugins.indexOf('webpack') !== -1) {
console.warn('no need to add dora-plugin-webpack, ignore it');
}

const tplDefault = join(root, tplSet.github);
let tplPath;
Expand Down Expand Up @@ -53,7 +58,6 @@ export default function (options) {
port,
resolveDir: join(root, 'node_modules'),
plugins: [
'proxy',
{
'middleware.before'() {
webpackConfig = getWebpackConfig(source, asset, dest, cwd, tplPath, config);
Expand Down Expand Up @@ -87,6 +91,7 @@ export default function (options) {
});
},
},
...plugins.filter(item => item !== 'webpack' && item !== 'dora-plugin-webpack'),
],
});
}
Expand Down

0 comments on commit d787e67

Please sign in to comment.