Skip to content
This repository was archived by the owner on Sep 8, 2021. It is now read-only.

Commit 1397583

Browse files
committed
add config ui
1 parent 7a828ea commit 1397583

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

ui.js

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
const fs = require('fs');
2+
const path = require('path');
3+
4+
function getConfigData(data) {
5+
return (data.vue && data.vue.pluginOptions && data.vue.pluginOptions.netlify) || {};
6+
}
7+
8+
module.exports = api => api.describeConfig({
9+
id: 'com.netlify.netlify-lambda',
10+
name: 'Netlify configuration',
11+
description: 'Configure Netlify Functions',
12+
link: 'https://github.com/netlify/vue-cli-plugin-netlify-lambda',
13+
files: {
14+
vue: {
15+
js: ['vue.config.js'],
16+
},
17+
},
18+
onRead({ data, cwd }) {
19+
return {
20+
prompts: [
21+
{
22+
name: 'webpackConfig',
23+
type: 'input',
24+
default: null,
25+
value: getConfigData(data).webpackConfig,
26+
validate: input => fs.existsSync(path.join(cwd, input)),
27+
message: 'Webpack config module',
28+
description: 'Additional webpack configuration',
29+
},
30+
],
31+
};
32+
},
33+
async onWrite({ api: writeApi, prompts }) {
34+
const result = {};
35+
for (const prompt of prompts) {
36+
result[`pluginOptions.netlify.${prompt.id}`] = await writeApi.getAnswer(prompt.id);
37+
}
38+
writeApi.setData('vue', result);
39+
},
40+
});

0 commit comments

Comments
 (0)