1
0
mirror of https://github.com/PanJiaChen/vue-element-admin.git synced 2025-09-07 18:39:47 +08:00
This commit is contained in:
Pan 2019-03-22 14:55:02 +08:00
parent ec7c585813
commit 8c091ce980
3 changed files with 77 additions and 1 deletions

View File

@ -13,7 +13,8 @@
"lint": "eslint --ext .js,.vue src",
"test": "npm run lint",
"test:unit": "vue-cli-service test:unit",
"svgo": "svgo -f src/icons/svg --config=src/icons/svgo.yml"
"svgo": "svgo -f src/icons/svg --config=src/icons/svgo.yml",
"new": "plop"
},
"husky": {
"hooks": {
@ -87,6 +88,7 @@
"lint-staged": "7.2.2",
"mockjs": "1.0.1-beta3",
"node-sass": "^4.9.0",
"plop": "2.3.0",
"runjs": "^4.3.2",
"sass-loader": "^7.1.0",
"script-ext-html-webpack-plugin": "2.1.3",

View File

@ -0,0 +1,13 @@
<template lang="pug">
div
{{banana}}
</template>
<script lang="ts">
import Vue from 'vue'
export default Vue.extend({
})
</script>
<style lang="scss" scoped>
</style>

61
plopfile.js Normal file
View File

@ -0,0 +1,61 @@
const notEmpty = name => {
return v => {
if (!v || v.trim === '') {
return `${name} is required`
} else {
return true
}
}
}
module.exports = function(plop) {
const name = '{{ properCase name }}'
plop.setGenerator('component', {
description: 'generate vue component',
prompts: [{
type: 'input',
name: 'name',
message: 'component name please',
validate: notEmpty('name')
},
{
type: 'checkbox',
name: 'blocks',
message: 'Blocks:',
choices: [
{
name: '<template>',
value: 'template',
checked: true
},
{
name: '<script>',
value: 'script',
checked: true
},
{
name: '<style>',
value: 'style',
checked: true
}
],
validate(value) {
if (value.indexOf('script') === -1 && value.indexOf('template') === -1) {
return 'Components require at least a <script> or <template> tag.'
}
return true
}
}
],
actions: [{
type: 'add',
path: `src/components/${name}/index.vue`,
templateFile: 'plop-templates/component/index.vue',
data: {
banana: 'banana'
}
}]
})
plop.setGenerator('none', {})
}