Skip to content

Commit f5f2ea5

Browse files
authored
feat: custom output file option (#46) (#47)
1 parent 06710c7 commit f5f2ea5

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ After adding the plugin, the file structure will be the below.
2222
src/
2323
├── pages/
2424
├── layouts/
25-
└── router.js
25+
└── router/
2626
```
2727

2828
### Pages
@@ -181,7 +181,9 @@ You can see the available options list [here](https://github.com/ktsn/vue-route-
181181
module.exports = {
182182
pluginOptions: {
183183
autoRouting: {
184-
// Specify vue-auto-routing options here
184+
// Optionally specify a custom output file, relative to the project root
185+
outFile: "src/router/routes.js",
186+
// Specify other vue-auto-routing options here
185187
nested: false
186188
}
187189
}

generator/template/src/router.js renamed to generator/template/src/router/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ const RouterLayout = createRouterLayout(layout => {
1010
})
1111

1212
export default new Router({
13+
mode: "history",
14+
base: process.env.BASE_URL,
1315
routes: [
1416
{
1517
path: '/',

index.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,11 @@ const defaultOptions = {
66
}
77

88
module.exports = (api, options) => {
9+
const opts = options.pluginOptions && options.pluginOptions.autoRouting
910
const pluginOptions = {
1011
...defaultOptions,
11-
...(options.pluginOptions && options.pluginOptions.autoRouting),
12+
...opts,
13+
outFile: (opts && opts.outFile && api.resolve(opts.outFile)) || undefined,
1214
}
1315

1416
api.chainWebpack((webpackConfig) => {

0 commit comments

Comments
 (0)