Skip to content

Commit 59be54e

Browse files
committed
Added some scaffolding to plugin generation
1 parent bd9464f commit 59be54e

File tree

15 files changed

+157
-3
lines changed

15 files changed

+157
-3
lines changed

generator/index.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,20 @@
11
module.exports = (api, { config }) => {
2+
const eslintConfig = { env: { webextensions: true } }
23
const pkg = {
34
scripts: {
45
'ext-serve': 'vue-cli-service ext-serve'
56
},
6-
devDependencies: {
7-
'vue-cli-plugin-build-watch': '^1.0.0'
7+
dependencies: {
8+
'vue-router': '^3.0.1',
9+
'vuex': '^3.0.1'
810
}
911
}
1012

13+
if (api.hasPlugin('eslint')) {
14+
console.log('Adding eslint config stuffs')
15+
pkg.eslintConfig = eslintConfig
16+
}
17+
1118
api.extendPackage(pkg)
19+
api.render('./template')
1220
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import store from './store'
2+
3+
chrome.browserAction.onClicked.addListener(function (tab) {
4+
console.log(`Hello ${store.getters.foo}!`)
5+
})
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
"manifest_version": 2,
3+
"icons": {
4+
"16": "icons/16.png",
5+
"48": "icons/48.png",
6+
"128": "icons/128.png"
7+
},
8+
"name": "<%- rootOptions.projectName %>",
9+
"homepage_url": "http://localhost/",
10+
"description": "A Vue Browser Extension",
11+
"version": "1.0",
12+
"permissions": ["activeTab", "http://*/*", "https://*/*"],
13+
"background": {
14+
"scripts": ["background.js"],
15+
"persistent": false
16+
},
17+
"browser_action": {
18+
"default_title": "<%- rootOptions.projectName %>",
19+
"default_icon": {
20+
"19": "icons/19.png",
21+
"38": "icons/38.png"
22+
},
23+
"default_popup": "popup/popup.html"
24+
},
25+
"background": {
26+
"scripts": [
27+
"background.js"
28+
]
29+
}
30+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<template>
2+
<div>
3+
<router-view></router-view>
4+
</div>
5+
</template>
6+
7+
<script>
8+
export default {
9+
data () {
10+
return {}
11+
}
12+
}
13+
</script>
14+
15+
<style>
16+
html {
17+
width: 400px;
18+
height: 400px;
19+
}
20+
</style>
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
6+
<meta name="viewport" content="width=device-width,initial-scale=1.0">
7+
<title><%- rootOptions.projectName %></title>
8+
<link rel="stylesheet" href="popup.css">
9+
</head>
10+
<body>
11+
<div id="app">
12+
13+
</div>
14+
<script src="popup.js"></script>
15+
</body>
16+
</html>
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import Vue from 'vue'
2+
import App from './App'
3+
import store from '../store'
4+
import router from './router'
5+
6+
/* eslint-disable no-new */
7+
new Vue({
8+
el: '#app',
9+
store,
10+
router,
11+
render: h => h(App)
12+
})
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import Vue from 'vue'
2+
import VueRouter from 'vue-router'
3+
import routes from './routes'
4+
5+
Vue.use(VueRouter)
6+
7+
export default new VueRouter({
8+
routes
9+
})
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<template>
2+
<p>Hello world!</p>
3+
</template>
4+
5+
<script>
6+
export default {
7+
data () {
8+
return {}
9+
}
10+
}
11+
</script>
12+
13+
<style scoped>
14+
p {
15+
font-size: 20px;
16+
}
17+
</style>
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import PageIndex from './pages/Index'
2+
3+
export default [
4+
{
5+
path: '/',
6+
component: PageIndex
7+
}
8+
]
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import * as types from './mutation-types'
2+
3+
export const setFoo = ({commit}, payload) => {
4+
commit(types.UPDATE_FOO, payload)
5+
}

0 commit comments

Comments
 (0)