Skip to content

Commit d787e67

Browse files
authored
[feat] open doraPlugins to specify, close #28 (#31)
* [feat] open doraPlugins to specify, close #28 * [fix] use compiler before all plugins
1 parent c9162f0 commit d787e67

File tree

3 files changed

+20
-13
lines changed

3 files changed

+20
-13
lines changed

README.md

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -70,16 +70,17 @@ $ npm i atool-doc -g
7070

7171
atool-doc [options]
7272

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

8586
## How to write demo file

bin/atool-doc.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ if (!process.send) {
2424
.option('--asset <dir>', 'config path of static resource, default statics', 'statics')
2525
.option('--tpl <path>', 'config path or name of tpl file')
2626
.option('--config <path>', 'config path of webpack.config, default webpack.config.js', 'webpack.config.js')
27-
.option('--port <number>', 'specify server port, default 8002', '8002')
27+
.option('--port <number>', 'specify dora server port, default 8002', '8002')
28+
.option('--doraPlugins <name|file>', 'defines the plugins which should used with dora server, default proxy', 'proxy')
2829
.option('--build', 'only build')
2930
.option('-w, --watch', 'using with --build, watch mode')
3031
.parse(process.argv);

src/doc.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,12 @@ import chokidar from 'chokidar';
99
const root = join(__dirname, '..');
1010

1111
export default function (options) {
12-
const { source, dest, cwd, tpl, config, port, asset } = options;
12+
const { source, dest, cwd, tpl, config, port, asset, doraPlugins } = options;
13+
14+
const plugins = doraPlugins ? doraPlugins.split(',') : [];
15+
if (plugins.indexOf('webpack') !== -1) {
16+
console.warn('no need to add dora-plugin-webpack, ignore it');
17+
}
1318

1419
const tplDefault = join(root, tplSet.github);
1520
let tplPath;
@@ -53,7 +58,6 @@ export default function (options) {
5358
port,
5459
resolveDir: join(root, 'node_modules'),
5560
plugins: [
56-
'proxy',
5761
{
5862
'middleware.before'() {
5963
webpackConfig = getWebpackConfig(source, asset, dest, cwd, tplPath, config);
@@ -87,6 +91,7 @@ export default function (options) {
8791
});
8892
},
8993
},
94+
...plugins.filter(item => item !== 'webpack' && item !== 'dora-plugin-webpack'),
9095
],
9196
});
9297
}

0 commit comments

Comments
 (0)