Skip to content

Commit 7f262dd

Browse files
committed
chore(example): update "full" example
1 parent 76a9770 commit 7f262dd

28 files changed

+7162
-0
lines changed

examples/full/.babelrc

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"plugins": [
3+
"@babel/plugin-proposal-optional-chaining"
4+
],
5+
"presets": [
6+
["@babel/preset-env", {
7+
"useBuiltIns": "usage",
8+
"corejs": 3,
9+
"targets": {
10+
// https://jamie.build/last-2-versions
11+
"browsers": ["> 0.25%", "not ie 11", "not op_mini all"]
12+
}
13+
}]
14+
]
15+
}

examples/full/.eslintrc.js

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
// https://eslint.org/docs/user-guide/configuring
2+
// File taken from https://github.com/vuejs-templates/webpack/blob/1.3.1/template/.eslintrc.js, thanks.
3+
4+
module.exports = {
5+
root: true,
6+
parserOptions: {
7+
parser: 'babel-eslint'
8+
},
9+
env: {
10+
browser: true,
11+
webextensions: true,
12+
},
13+
extends: [
14+
// https://github.com/vuejs/eslint-plugin-vue#priority-a-essential-error-prevention
15+
// consider switching to `plugin:vue/strongly-recommended` or `plugin:vue/recommended` for stricter rules.
16+
'plugin:vue/essential',
17+
// https://github.com/standard/standard/blob/master/docs/RULES-en.md
18+
'standard',
19+
// https://prettier.io/docs/en/index.html
20+
'plugin:prettier/recommended'
21+
],
22+
// required to lint *.vue files
23+
plugins: [
24+
'vue'
25+
],
26+
// add your custom rules here
27+
rules: {
28+
// allow async-await
29+
'generator-star-spacing': 'off',
30+
// allow debugger during development
31+
'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off'
32+
}
33+
}

examples/full/.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
/node_modules
2+
/*.log
3+
/dist
4+
/dist-zip

examples/full/.prettierrc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"singleQuote": true,
3+
"printWidth": 180,
4+
"trailingComma": "es5"
5+
}

examples/full/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Project: full
2+
3+
This project has been generated with `vue init kocal/vue-web-extension .` command, following [full scenario](../../scenarios/minimal.json).

examples/full/package.json

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
{
2+
"name": "full",
3+
"version": "1.0.0",
4+
"description": "Extension generated with Kocal/vue-web-extension",
5+
"author": "Travis",
6+
"license": "MIT",
7+
"scripts": {
8+
"lint": "eslint --ext .js,.vue src",
9+
"precommit": "pretty-quick --staged",
10+
"prettier": "prettier \"src/**/*.{js,vue}\"",
11+
"prettier:write": "npm run prettier -- --write",
12+
"build": "cross-env NODE_ENV=production webpack --hide-modules",
13+
"build:dev": "cross-env NODE_ENV=development webpack --hide-modules",
14+
"build-zip": "node scripts/build-zip.js",
15+
"watch": "npm run build -- --watch",
16+
"watch:dev": "cross-env HMR=true npm run build:dev -- --watch"
17+
},
18+
"dependencies": {
19+
"axios": "^0.18.0",
20+
"vue": "^2.6.10",
21+
"vue-router": "^3.0.1",
22+
"vuex": "^3.0.1",
23+
"webextension-polyfill": "^0.3.1"
24+
},
25+
"devDependencies": {
26+
"@babel/core": "^7.1.2",
27+
"@babel/plugin-proposal-optional-chaining": "^7.0.0",
28+
"@babel/preset-env": "^7.1.0",
29+
"@babel/runtime-corejs3": "^7.4.0",
30+
"archiver": "^3.0.0",
31+
"babel-eslint": "^10.0.1",
32+
"babel-loader": "^8.0.2",
33+
"copy-webpack-plugin": "^4.5.3",
34+
"core-js": "^3.0.1",
35+
"cross-env": "^5.2.0",
36+
"css-loader": "^0.28.11",
37+
"ejs": "^2.6.1",
38+
"eslint": "^5.16.0",
39+
"eslint-config-prettier": "^3.1.0",
40+
"eslint-config-standard": "^12.0.0",
41+
"eslint-friendly-formatter": "^4.0.1",
42+
"eslint-loader": "^2.1.2",
43+
"eslint-plugin-import": "^2.16.0",
44+
"eslint-plugin-node": "^7.0.1",
45+
"eslint-plugin-prettier": "^3.0.1",
46+
"eslint-plugin-promise": "^4.1.1",
47+
"eslint-plugin-standard": "^4.0.0",
48+
"eslint-plugin-vue": "^5.2.2",
49+
"file-loader": "^1.1.11",
50+
"husky": "^0.14.3",
51+
"mini-css-extract-plugin": "^0.4.4",
52+
"node-sass": "^4.9.3",
53+
"prettier": "^1.14.3",
54+
"pretty-quick": "^1.8.0",
55+
"sass-loader": "^7.1.0",
56+
"vue-loader": "^15.4.2",
57+
"vue-template-compiler": "^2.6.10",
58+
"web-ext-types": "^2.1.0",
59+
"webpack": "^4.20.2",
60+
"webpack-chrome-extension-reloader": "^0.8.3",
61+
"webpack-cli": "^3.1.2"
62+
}
63+
}

examples/full/scripts/build-zip.js

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
#!/usr/bin/env node
2+
3+
const fs = require('fs');
4+
const path = require('path');
5+
const archiver = require('archiver');
6+
7+
const DEST_DIR = path.join(__dirname, '../dist');
8+
const DEST_ZIP_DIR = path.join(__dirname, '../dist-zip');
9+
10+
const extractExtensionData = () => {
11+
const extPackageJson = require('../package.json');
12+
13+
return {
14+
name: extPackageJson.name,
15+
version: extPackageJson.version
16+
}
17+
};
18+
19+
const makeDestZipDirIfNotExists = () => {
20+
if(!fs.existsSync(DEST_ZIP_DIR)) {
21+
fs.mkdirSync(DEST_ZIP_DIR);
22+
}
23+
}
24+
25+
const buildZip = (src, dist, zipFilename) => {
26+
console.info(`Building ${zipFilename}...`);
27+
28+
const archive = archiver('zip', { zlib: { level: 9 }});
29+
const stream = fs.createWriteStream(path.join(dist, zipFilename));
30+
31+
return new Promise((resolve, reject) => {
32+
archive
33+
.directory(src, false)
34+
.on('error', err => reject(err))
35+
.pipe(stream);
36+
37+
stream.on('close', () => resolve());
38+
archive.finalize();
39+
});
40+
};
41+
42+
const main = () => {
43+
const {name, version} = extractExtensionData();
44+
const zipFilename = `${name}-v${version}.zip`;
45+
46+
makeDestZipDirIfNotExists();
47+
48+
buildZip(DEST_DIR, DEST_ZIP_DIR, zipFilename)
49+
.then(() => console.info('OK'))
50+
.catch(console.err);
51+
};
52+
53+
main();

examples/full/src/background.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import store from './store';
2+
global.browser = require('webextension-polyfill');
3+
4+
alert(`Hello ${store.getters.foo}!`);

examples/full/src/icons/icon.xcf

43.1 KB
Binary file not shown.
9.81 KB
Loading

0 commit comments

Comments
 (0)