Skip to content

Commit 275c442

Browse files
feature: Initial plugin examples and slides from the VueDC presentation on October 17, 2018
1 parent 83336ef commit 275c442

File tree

9 files changed

+177
-2
lines changed

9 files changed

+177
-2
lines changed

README.md

+20-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,20 @@
1-
# vue-cli-3-walkthrough
2-
A walkthrough of Vue CLI 3's feature set with a focus on Plugin Development
1+
# Vue CLI 3 Walkthrough
2+
3+
## About
4+
5+
**Created:** October 17, 2018
6+
7+
**Speaker:** Christian Guirreri ([@politicochris](https://twitter.com/politicochris))
8+
9+
## Resources
10+
11+
* Recording - 2018.10.17 - Coming Soon
12+
* [Slides - 2018.10.17](https://github.com/VueDC/vue-cli-3-walkthrough/blob/master/slides/2018-10-17-vue-cli-3-walkthrough.pdf)
13+
* [Vue CLI 3 Plugin Development Guide](https://cli.vuejs.org/dev-guide/plugin-dev.html)
14+
15+
## To Do
16+
17+
* [ ] Show an example of updating (rather than replacing) [Generator templates](https://cli.vuejs.org/dev-guide/plugin-dev.html#generator-templating) with yaml
18+
* [ ] Show an example of webpack modification with the [Service Plugin](https://cli.vuejs.org/dev-guide/plugin-dev.html#service-plugin)
19+
* [ ] Show an example of [modifying built-in plugins via promts](https://cli.vuejs.org/dev-guide/plugin-dev.html#prompts)
20+
* [ ] Show more detail about each of the undocumented options and functions available in the [PluginAPI](https://github.com/vuejs/vue-cli/blob/dev/packages/%40vue/cli-service/lib/PluginAPI.js), the [GeneratorAPI](https://github.com/vuejs/vue-cli/blob/dev/packages/%40vue/cli/lib/GeneratorAPI.js), [PromptModuleAPI](https://github.com/vuejs/vue-cli/blob/dev/packages/%40vue/cli/lib/PromptModuleAPI.js) and [Inquirer.js](https://github.com/SBoudrias/Inquirer.js)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
module.exports = (api, options, rootOptions) => {
2+
// Generator
3+
// This file will execute...
4+
// 1) If the plugin is included in the preset
5+
// 2) During the invoke command, after the plugin is installed
6+
// Docs: https://cli.vuejs.org/dev-guide/plugin-dev.html#generator
7+
// Creator Class: https://github.com/vuejs/vue-cli/blob/dev/packages/%40vue/cli/lib/Creator.js
8+
// Generator API Code: https://github.com/vuejs/vue-cli/blob/dev/packages/%40vue/cli/lib/GeneratorAPI.js
9+
10+
// Arguments:
11+
// api: Generator API
12+
// options: Generator options for this plugin, or options from the preset
13+
// rootOptions: The preset used to create the project
14+
15+
// Modify an eslint rule based on an inputted option. Default is false.
16+
const eslintConfig = {
17+
rules: {}
18+
}
19+
if (options.forceComponentOrder) {
20+
eslintConfig.rules['vue/order-in-components'] = 'error'
21+
} else {
22+
eslintConfig.rules['vue/order-in-components'] = 'never'
23+
}
24+
25+
// Modify package.json fields
26+
api.extendPackage({
27+
dependencies: {
28+
axios: "^0.18.0"
29+
},
30+
eslintConfig
31+
});
32+
33+
api.onCreateComplete(() => {
34+
// Delete a file
35+
// TODO: Delete a folder if it's empty
36+
// const fs = require('fs');
37+
// const filename = api.resolve('HelloVueDC.vue');
38+
// const fileExists = fs.existsSync(filename);
39+
// if (fileExists) {
40+
// fs.unlink(filename, function(error) {
41+
// if (error) {
42+
// throw error;
43+
// }
44+
// console.log('Deleted filename', filename);
45+
// });
46+
// }
47+
})
48+
49+
// Copy and render all files in ./template with ejs
50+
api.render("./template", {
51+
...options,
52+
});
53+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
module.exports = (api, projectOptions) => {
2+
// Service
3+
// This file will execute...
4+
// 1) Anytime when vue-cli-service is started
5+
// Docs: https://cli.vuejs.org/dev-guide/plugin-dev.html#service-plugin
6+
// Service Class: https://github.com/vuejs/vue-cli/blob/dev/packages/%40vue/cli-service/lib/Service.js
7+
// Plugin API Code: https://github.com/vuejs/vue-cli/blob/dev/packages/%40vue/cli-service/lib/PluginAPI.js
8+
9+
// Arguments:
10+
// api: Plugin API
11+
// projectOptions: vue.config.js or the "vue" field in package.json
12+
13+
api.chainWebpack(webpackConfig => {
14+
// modify webpack config with webpack-chain
15+
});
16+
17+
api.configureWebpack(webpackConfig => {
18+
// modify webpack config or return object to be merged with webpack-merge
19+
});
20+
21+
api.registerCommand("build", args => {
22+
// do something when running `vue-cli-service build`
23+
});
24+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"name": "vue-cli-plugin-vuedc-init",
3+
"version": "0.9.9-alpha.1",
4+
"description": "Vue CLI 3 Plugin for a VueDC Presentation",
5+
"main": "index.js",
6+
"scripts": {
7+
"test": "echo \"Error: no test specified\" && exit 1"
8+
},
9+
"author": "Christian Guirreri",
10+
"license": "ISC"
11+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"useConfigFiles": true,
3+
"plugins": {
4+
"@vue/cli-plugin-babel": {},
5+
"@vue/cli-plugin-eslint": {
6+
"config": "standard",
7+
"lintOn": ["save"]
8+
}
9+
},
10+
"cssPreprocessor": "sass"
11+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
module.exports = [
2+
{
3+
name: `forceComponentOrder`,
4+
type: "confirm",
5+
message: "WHen linting, do you want to force the order of properties in components?",
6+
default: false
7+
}
8+
];
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<template>
2+
<div id="app">
3+
<img alt="Vue logo" src="./assets/logo.png">
4+
<HelloWorld msg="Welcome to Your Vue.js App"/>
5+
<HelloVueDC title="Hello VueDC!"/>
6+
</div>
7+
</template>
8+
9+
<script>
10+
import HelloWorld from './components/HelloWorld.vue'
11+
import HelloVueDC from './components/HelloVueDC.vue'
12+
13+
export default {
14+
name: 'app',
15+
components: {
16+
HelloWorld,
17+
HelloVueDC
18+
}
19+
}
20+
</script>
21+
22+
<style lang="scss">
23+
#app {
24+
font-family: 'Avenir', Helvetica, Arial, sans-serif;
25+
-webkit-font-smoothing: antialiased;
26+
-moz-osx-font-smoothing: grayscale;
27+
text-align: center;
28+
color: #2c3e50;
29+
margin-top: 60px;
30+
}
31+
</style>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<script>
2+
export default {
3+
data () {
4+
return {
5+
}
6+
},
7+
name: 'HelloVueDC',
8+
props: {
9+
title: ''
10+
}
11+
}
12+
</script>
13+
14+
<template>
15+
<h1>{{ title }}</h1>
16+
</template>
17+
18+
<style lang="sass" scoped>
19+
</style>
Binary file not shown.

0 commit comments

Comments
 (0)